summaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/quaternion.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dev/MinGfx/src/quaternion.cc')
-rw-r--r--dev/MinGfx/src/quaternion.cc19
1 files changed, 10 insertions, 9 deletions
diff --git a/dev/MinGfx/src/quaternion.cc b/dev/MinGfx/src/quaternion.cc
index 4f2998f..24830c8 100644
--- a/dev/MinGfx/src/quaternion.cc
+++ b/dev/MinGfx/src/quaternion.cc
@@ -116,12 +116,13 @@ Quaternion Quaternion::Slerp(const Quaternion &other, float alpha) const {
return result;
}
- GfxMath::Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()
- float theta_0 = acos(dot); // theta_0 = angle between input vectors
- float theta = theta_0 * alpha; // theta = angle between v0 and result
+ GfxMath::Clamp(dot, -1, 1); // Robustness: Stay within domain of acos()
+ float theta_0 = GfxMath::acos(dot); // theta_0 = angle between input vectors
+ float theta = theta_0 * alpha; // theta = angle between v0 and result
- float s0 = cos(theta) - dot * sin(theta) / sin(theta_0); // == sin(theta_0 - theta) / sin(theta_0)
- float s1 = sin(theta) / sin(theta_0);
+ float s0 = GfxMath::cos(theta) - dot
+ * GfxMath::sin(theta) / GfxMath::sin(theta_0); // == sin(theta_0 - theta) / sin(theta_0)
+ float s1 = GfxMath::sin(theta) / GfxMath::sin(theta_0);
return (s0 * v0) + (s1 * v1);
}
@@ -177,10 +178,10 @@ Quaternion Quaternion::Conjugate() const {
Quaternion Quaternion::FromAxisAngle(const Vector3 &axis, float angle) {
// [qx, qy, qz, qw] = [sin(a/2) * vx, sin(a/2)* vy, sin(a/2) * vz, cos(a/2)]
- float x = sin(angle/2.0f) * axis[0];
- float y = sin(angle/2.0f) * axis[1];
- float z = sin(angle/2.0f) * axis[2];
- float w = cos(angle/2.0f);
+ float x = GfxMath::sin(angle/2.0) * axis[0];
+ float y = GfxMath::sin(angle/2.0) * axis[1];
+ float z = GfxMath::sin(angle/2.0) * axis[2];
+ float w = GfxMath::cos(angle/2.0);
return Quaternion(x,y,z,w);
}