mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 05:38:56 +00:00
MATH: Add fromEuler() to Math::Quaternion
This commit is contained in:
parent
0b5a4b0cd1
commit
9541c89859
@ -102,4 +102,24 @@ Matrix4 Quaternion::toMatrix() {
|
||||
return dst;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::fromEuler(const Angle & yaw, const Angle & pitch, const Angle & roll) {
|
||||
float cr, cp, cy, sr, sp, sy, cpcy, spsy;
|
||||
|
||||
cy = (yaw / 2).getCosine();
|
||||
cp = (pitch / 2).getCosine();
|
||||
cr = (roll / 2).getCosine();
|
||||
|
||||
sy = (yaw / 2).getSine();
|
||||
sp = (pitch / 2).getSine();
|
||||
sr = (roll / 2).getSine();
|
||||
|
||||
cpcy = cp * cy;
|
||||
spsy = sp * sy;
|
||||
|
||||
return Quaternion(
|
||||
cr * sp * cy + sr * cp * sy,
|
||||
cr * cp * sy - sr * sp * cy,
|
||||
sr * cpcy - cr * spsy,
|
||||
cr * cpcy + sr * spsy);
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
* @return the resulting quaternion.
|
||||
*/
|
||||
Quaternion slerpQuat(const Quaternion& to, const float t);
|
||||
static Quaternion fromEuler(const Angle & yaw, const Angle & pitch, const Angle & roll);
|
||||
|
||||
inline static Quaternion get_quaternion(const char *data) {
|
||||
return Quaternion(get_float(data), get_float(data + 4), get_float(data + 8), get_float(data + 12));
|
||||
|
Loading…
Reference in New Issue
Block a user