From 1d8d7c04786ab3964778e6f21fae145f661bb533 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Thu, 4 Apr 2024 19:45:19 +1100 Subject: loading textures --- src/maths/maths.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/maths/maths.h') diff --git a/src/maths/maths.h b/src/maths/maths.h index d832739..95ced1d 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() { -- cgit v1.2.3-70-g09d2 From 0063d8b927dd55f34906bdcd356aff99c2a96a86 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Thu, 4 Apr 2024 19:49:20 +1100 Subject: chore: format --- src/maths/maths.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/maths/maths.h') diff --git a/src/maths/maths.h b/src/maths/maths.h index 95ced1d..d1e850d 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -67,15 +67,15 @@ 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); + 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; + quat q = (quat){ s * axis.x, s * axis.y, s * axis.z, c }; + if (normalize) { + return quat_normalise(q); + } + return q; } // --- Matrix Implementations -- cgit v1.2.3-70-g09d2