mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 13:50:13 +00:00
MATH: Add a vector rotation method to the Quaternion class
This commit is contained in:
parent
f0a9dfe70e
commit
f7407f35f2
@ -114,6 +114,11 @@ Quaternion& Quaternion::normalize() {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Quaternion::transform(Vector3d &v) const {
|
||||
const Vector3d im = Vector3d(x(), y(), z());
|
||||
v += 2.0 * Vector3d::crossProduct(im, Vector3d::crossProduct(im, v) + w() * v);
|
||||
}
|
||||
|
||||
void Quaternion::fromMatrix(const Matrix3 &m) {
|
||||
float qx, qy, qz, qw;
|
||||
float tr = m.getValue(0, 0) + m.getValue(1, 1) + m.getValue(2, 2);
|
||||
|
@ -159,6 +159,12 @@ public:
|
||||
*/
|
||||
Quaternion &normalize();
|
||||
|
||||
/**
|
||||
* Rotate a vector by a Quaternion
|
||||
* @param v The Vector to be rotated
|
||||
*/
|
||||
void transform(Vector3d &v) const;
|
||||
|
||||
/**
|
||||
* Converts from this Quaternion to a Matrix4 representation
|
||||
* @return The resulting matrix
|
||||
|
Loading…
Reference in New Issue
Block a user