|
@@ -1323,31 +1323,27 @@ var BABYLON;
|
|
|
return this;
|
|
|
};
|
|
|
Quaternion.prototype.toRotationMatrix = function (result) {
|
|
|
- var xx = this.x * this.x;
|
|
|
- var yy = this.y * this.y;
|
|
|
- var zz = this.z * this.z;
|
|
|
- var xy = this.x * this.y;
|
|
|
- var zw = this.z * this.w;
|
|
|
- var zx = this.z * this.x;
|
|
|
- var yw = this.y * this.w;
|
|
|
- var yz = this.y * this.z;
|
|
|
- var xw = this.x * this.w;
|
|
|
- result.m[0] = 1.0 - (2.0 * (yy + zz));
|
|
|
- result.m[1] = 2.0 * (xy + zw);
|
|
|
- result.m[2] = 2.0 * (zx - yw);
|
|
|
+ var x = this.x, y = this.y, z = this.z, w = this.w;
|
|
|
+ var x2 = x + x, y2 = y + y, z2 = z + z;
|
|
|
+ var xx = x * x2, xy = x * y2, xz = x * z2;
|
|
|
+ var yy = y * y2, yz = y * z2, zz = z * z2;
|
|
|
+ var wx = w * x2, wy = w * y2, wz = w * z2;
|
|
|
+ result.m[0] = 1 - (yy + zz);
|
|
|
+ result.m[4] = xy - wz;
|
|
|
+ result.m[8] = xz + wy;
|
|
|
+ result.m[1] = xy + wz;
|
|
|
+ result.m[5] = 1 - (xx + zz);
|
|
|
+ result.m[9] = yz - wx;
|
|
|
+ result.m[2] = xz - wy;
|
|
|
+ result.m[6] = yz + wx;
|
|
|
+ result.m[10] = 1 - (xx + yy);
|
|
|
result.m[3] = 0;
|
|
|
- result.m[4] = 2.0 * (xy - zw);
|
|
|
- result.m[5] = 1.0 - (2.0 * (zz + xx));
|
|
|
- result.m[6] = 2.0 * (yz + xw);
|
|
|
result.m[7] = 0;
|
|
|
- result.m[8] = 2.0 * (zx + yw);
|
|
|
- result.m[9] = 2.0 * (yz - xw);
|
|
|
- result.m[10] = 1.0 - (2.0 * (yy + xx));
|
|
|
result.m[11] = 0;
|
|
|
result.m[12] = 0;
|
|
|
result.m[13] = 0;
|
|
|
result.m[14] = 0;
|
|
|
- result.m[15] = 1.0;
|
|
|
+ result.m[15] = 1;
|
|
|
return this;
|
|
|
};
|
|
|
Quaternion.prototype.fromRotationMatrix = function (matrix) {
|