quaternion: fix incorrect factorisation in as_matrix
One of the terms in m[0][0] and m[1][1] was incorrectly negated from an incomplete factorisation when I transcribed the formula. Also reintroduces the axis-rotation tests which inadvertantly had zero magnitudes.
This commit is contained in:
parent
798d3aac5a
commit
c917f264c4
@ -111,8 +111,8 @@ quaternion<S, T>::as_matrix (void) const
|
||||
const T yy = this->y * this->y, yz = this->y * this->z, zz = this->z * this->z;
|
||||
|
||||
return { {
|
||||
{ 1 - 2 * (yy - zz), 2 * (xy - wz), 2 * (xz + wy), 0 },
|
||||
{ 2 * (xy + wz), 1 - 2 * (xx - zz), 2 * (yz - wx), 0 },
|
||||
{ 1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy), 0 },
|
||||
{ 2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx), 0 },
|
||||
{ 2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy), 0 },
|
||||
{ 0, 0, 0, 1 }
|
||||
} };
|
||||
|
@ -68,9 +68,9 @@ main (void)
|
||||
float mag;
|
||||
util::vector3f axis;
|
||||
} ROTATIONS[] = {
|
||||
{ 0.f, { 1.f, 0.f, 0.f } },
|
||||
{ 1.f, { 1.f, 0.f, 0.f } },
|
||||
{ 1.f, { 0.f, 1.f, 0.f } },
|
||||
{ 0.f, { 0.f, 0.f, 1.f } },
|
||||
{ 1.f, { 0.f, 0.f, 1.f } },
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < elems (ROTATIONS); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user