mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1304886
- Part 7: Add mulitiplications for quaternions. r=boris,derf
MozReview-Commit-ID: IZDnU26wj2Y --HG-- extra : rebase_source : 492e2cb6aa8dc40d5f07661f4a5bac9061d2cca2
This commit is contained in:
parent
7edca15eba
commit
7a9cc3600d
@ -72,6 +72,29 @@ struct gfxQuaternion : public mozilla::gfx::BasePoint4D<gfxFloat, gfxQuaternion>
|
||||
return left + right;
|
||||
}
|
||||
|
||||
using Super::operator*=;
|
||||
|
||||
// Quaternion multiplication
|
||||
// Reference:
|
||||
// https://en.wikipedia.org/wiki/Quaternion#Ordered_list_form
|
||||
//
|
||||
// (w1, x1, y1, z1)(w2, x2, y2, z2) = (w1w2 - x1x2 - y1y2 - z1z2,
|
||||
// w1x2 + x1w2 + y1z2 - z1y2,
|
||||
// w1y2 - x1z2 + y1w2 + z1x2,
|
||||
// w1z2 + x1y2 - y1x2 + z1w2)
|
||||
gfxQuaternion operator*(const gfxQuaternion& aOther) const {
|
||||
return gfxQuaternion(
|
||||
w * aOther.x + x * aOther.w + y * aOther.z - z * aOther.y,
|
||||
w * aOther.y - x * aOther.z + y * aOther.w + z * aOther.x,
|
||||
w * aOther.z + x * aOther.y - y * aOther.x + z * aOther.w,
|
||||
w * aOther.w - x * aOther.x - y * aOther.y - z * aOther.z
|
||||
);
|
||||
}
|
||||
gfxQuaternion& operator*=(const gfxQuaternion& aOther) {
|
||||
*this = *this * aOther;
|
||||
return *this;
|
||||
}
|
||||
|
||||
mozilla::gfx::Matrix4x4 ToMatrix() const {
|
||||
mozilla::gfx::Matrix4x4 temp;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user