mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
New custom math functions
* AngleCompose (compose angle from 2 angles). * AngleLerp (linearly interpolate first angle to second). * AngleInverse (invert input angle).
This commit is contained in:
parent
86c9ac5292
commit
75abedc711
@ -1214,6 +1214,9 @@ int InsideOut(int nTotal, int nCounter);
|
||||
// FIXME: Vector versions.... the float versions will go away hopefully soon!
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AngleCompose(const QAngle& a1, const QAngle& a2, QAngle& out);
|
||||
void AngleLerp(const QAngle& a1, const QAngle& a2, float t, QAngle& out);
|
||||
void AngleInverse(const QAngle& angles, QAngle& out);
|
||||
void AngleVectors(const QAngle& angles, Vector3D* forward);
|
||||
void AngleVectors(const QAngle& angles, Vector3D* forward, Vector3D* right, Vector3D* up);
|
||||
void AngleVectorsTranspose(const QAngle& angles, Vector3D* forward, Vector3D* right, Vector3D* up);
|
||||
|
@ -1002,6 +1002,50 @@ int __cdecl BoxOnPlaneSide(const float* emins, const float* emaxs, const cplane_
|
||||
return sides;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Euler QAngle -> Euler QAngle Composed
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AngleCompose(const QAngle& a1, const QAngle& a2, QAngle& out)
|
||||
{
|
||||
Quaternion q1, q2, q3;
|
||||
|
||||
AngleQuaternion(a1, q1);
|
||||
AngleQuaternion(a2, q2);
|
||||
|
||||
QuaternionMult(q1, q2, q3);
|
||||
QuaternionAngles(q3, out);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Euler QAngle -> Euler QAngle Lerped
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AngleLerp(const QAngle& a1, const QAngle& a2, float t, QAngle& out)
|
||||
{
|
||||
Quaternion q1, q2, q3;
|
||||
|
||||
AngleQuaternion(a1, q1);
|
||||
AngleQuaternion(a2, q2);
|
||||
|
||||
QuaternionSlerp(q1, q2, t, q3);
|
||||
QuaternionAngles(q3, out);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Euler QAngle -> Euler QAngle Inverted
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AngleInverse(const QAngle& angles, QAngle& out)
|
||||
{
|
||||
Quaternion q1, q2;
|
||||
|
||||
AngleQuaternion(angles, q1);
|
||||
|
||||
QuaternionInvert(q1, q2);
|
||||
QuaternionAngles(q2, out);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Euler QAngle -> Basis Vectors
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user