diff options
author | Joshua Rowe <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-04 19:50:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 19:50:49 +1100 |
commit | b7d8ca95d38942eb3d3c308392c73fda1858efd1 (patch) | |
tree | 55b06b524424ff77af00c907180928b5cf74718c /src/maths/maths.h | |
parent | 0ba447ee95c31e132b4ca91671dfe10ad29bca32 (diff) | |
parent | 0063d8b927dd55f34906bdcd356aff99c2a96a86 (diff) |
Merge pull request #8 from omnisci3nce/cel-56-load-gltf-files
Cel 56 load gltf files
Diffstat (limited to 'src/maths/maths.h')
-rw-r--r-- | src/maths/maths.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/maths/maths.h b/src/maths/maths.h index b6e380c..57d575d 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -66,6 +66,18 @@ static inline quat quat_normalise(quat a) { static inline quat quat_ident() { return (quat){ .x = 0.0, .y = 0.0, .z = 0.0, .w = 1.0 }; } +static quat quat_from_axis_angle(vec3 axis, f32 angle, bool normalize) { + const f32 half_angle = 0.5f * angle; + f32 s = sinf(half_angle); + f32 c = cosf(half_angle); + + quat q = (quat){ s * axis.x, s * axis.y, s * axis.z, c }; + if (normalize) { + return quat_normalise(q); + } + return q; +} + // --- Matrix Implementations static inline mat4 mat4_ident() { |