copyRotationInto method Null safety
- Matrix3 rotationMatrix
Set rotationMatrix
to a rotation matrix containing the same rotation as
this.
Implementation
Matrix3 copyRotationInto(Matrix3 rotationMatrix) {
final d = length2;
assert(d != 0.0);
final s = 2.0 / d;
final _x = _qStorage[0];
final _y = _qStorage[1];
final _z = _qStorage[2];
final _w = _qStorage[3];
final xs = _x * s;
final ys = _y * s;
final zs = _z * s;
final wx = _w * xs;
final wy = _w * ys;
final wz = _w * zs;
final xx = _x * xs;
final xy = _x * ys;
final xz = _x * zs;
final yy = _y * ys;
final yz = _y * zs;
final zz = _z * zs;
final rotationMatrixStorage = rotationMatrix.storage;
rotationMatrixStorage[0] = 1.0 - (yy + zz); // column 0
rotationMatrixStorage[1] = xy + wz;
rotationMatrixStorage[2] = xz - wy;
rotationMatrixStorage[3] = xy - wz; // column 1
rotationMatrixStorage[4] = 1.0 - (xx + zz);
rotationMatrixStorage[5] = yz + wx;
rotationMatrixStorage[6] = xz + wy; // column 2
rotationMatrixStorage[7] = yz - wx;
rotationMatrixStorage[8] = 1.0 - (xx + yy);
return rotationMatrix;
}