From 5de20c1670ed7116143ab704919800d8ae1bed4d Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Mon, 16 Sep 2024 19:56:05 -0700 Subject: Add function for global Y-axis rotation. --- include/math/spatial3.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/math/spatial3.h b/include/math/spatial3.h index 9065972..49e5615 100644 --- a/include/math/spatial3.h +++ b/include/math/spatial3.h @@ -107,6 +107,11 @@ static inline void spatial3_roll(Spatial3* spatial, const R angle) { spatial->r = vec3_normalize(vec3_cross(spatial->f, spatial->u)); } +/// Rotate the spatial about the global Y axis. +static inline void spatial3_global_yaw(Spatial3* spatial, const R angle) { + spatial3_rotate(spatial, up3(), angle); +} + /// Set the spatial's transformation matrix. static inline void spatial3_set_transform(Spatial3* spatial, mat4 transform) { spatial->r = mat4_v0(transform); @@ -115,6 +120,7 @@ static inline void spatial3_set_transform(Spatial3* spatial, mat4 transform) { spatial->p = mat4_v3(transform); } +/// Set the spatial's forward vector. static inline void spatial3_set_forward(Spatial3* spatial, vec3 forward) { spatial->f = vec3_normalize(forward); // Use aux vector to define right vector orthogonal to forward. -- cgit v1.2.3