mirror of
https://github.com/AxioDL/zeus.git
synced 2025-06-25 16:03:35 +00:00
Proper getAngleDiff implementations
This commit is contained in:
parent
a240b39a11
commit
cb4ede8097
@ -9,12 +9,11 @@ float CVector2f::getAngleDiff(const CVector2f& a, const CVector2f& b) {
|
||||
float mag1 = a.magnitude();
|
||||
float mag2 = b.magnitude();
|
||||
|
||||
if (!mag1 || !mag2)
|
||||
return 0;
|
||||
if (mag1 <= FLT_EPSILON || mag2 <= FLT_EPSILON)
|
||||
return 0.f;
|
||||
|
||||
float dot = a.dot(b);
|
||||
float theta = std::acos(dot / (mag1 * mag2));
|
||||
return theta;
|
||||
return std::acos(zeus::clamp(-1.f, dot / (mag1 * mag2), 1.f));
|
||||
}
|
||||
|
||||
CVector2f CVector2f::slerp(const CVector2f& a, const CVector2f& b, float t) {
|
||||
|
@ -11,12 +11,11 @@ float CVector3f::getAngleDiff(const CVector3f& a, const CVector3f& b) {
|
||||
float mag1 = a.magnitude();
|
||||
float mag2 = b.magnitude();
|
||||
|
||||
if (!mag1 || !mag2)
|
||||
if (mag1 <= FLT_EPSILON || mag2 <= FLT_EPSILON)
|
||||
return 0.f;
|
||||
|
||||
float dot = a.dot(b);
|
||||
float theta = std::acos(dot / (mag1 * mag2));
|
||||
return theta;
|
||||
return std::acos(zeus::clamp(-1.f, dot / (mag1 * mag2), 1.f));
|
||||
}
|
||||
|
||||
CVector3f CVector3f::slerp(const CVector3f& a, const CVector3f& b, CRelAngle clampAngle) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user