summaryrefslogtreecommitdiffhomepage
path: root/src/raymath.h
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2021-07-27 23:30:08 +0200
committerraysan5 <[email protected]>2021-07-27 23:30:08 +0200
commit70ed52dd5d972a33268b603930ffbb9e1338da24 (patch)
treec8bc587a47c4b8819b11226b049677b12c32cf6d /src/raymath.h
parent4e363b5479b59fbb41abe61a4e9c2ef8394294af (diff)
downloadraylib-70ed52dd5d972a33268b603930ffbb9e1338da24.tar.gz
raylib-70ed52dd5d972a33268b603930ffbb9e1338da24.zip
REVIEWED: QuaternionFromAxisAngle() #1892
Diffstat (limited to 'src/raymath.h')
-rw-r--r--src/raymath.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/raymath.h b/src/raymath.h
index ea888cf0..13cb5e17 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -1422,20 +1422,21 @@ RMDEF Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle)
Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f };
if (Vector3Length(axis) != 0.0f)
+ {
+ angle *= 0.5f;
- angle *= 0.5f;
-
- axis = Vector3Normalize(axis);
+ axis = Vector3Normalize(axis);
- float sinres = sinf(angle);
- float cosres = cosf(angle);
+ float sinres = sinf(angle);
+ float cosres = cosf(angle);
- result.x = axis.x*sinres;
- result.y = axis.y*sinres;
- result.z = axis.z*sinres;
- result.w = cosres;
+ result.x = axis.x*sinres;
+ result.y = axis.y*sinres;
+ result.z = axis.z*sinres;
+ result.w = cosres;
- result = QuaternionNormalize(result);
+ result = QuaternionNormalize(result);
+ }
return result;
}