RotationMatrix constructor
Build a rotation matrix for rotations about the line through (a, b, c)
parallel to u, v, w
by the angle theta.
a
x-coordinate of a point on the line of rotation.
b
y-coordinate of a point on the line of rotation.
c
z-coordinate of a point on the line of rotation.
uUn
x-coordinate of the line's direction vector (unnormalized).
vUn
y-coordinate of the line's direction vector (unnormalized).
wUn
z-coordinate of the line's direction vector (unnormalized).
theta
The angle of rotation, in radians.
Implementation
RotationMatrix(double a, double b, double c, double uUn, double vUn,
double wUn, double theta) {
final l = _longEnough(uUn, vUn, wUn);
assert(l > 0, 'RotationMatrix: direction vector too short!');
// In this instance we normalize the direction vector.
final u = uUn / l;
final v = vUn / l;
final w = wUn / l;
// Set some intermediate values.
final u2 = u * u;
final v2 = v * v;
final w2 = w * w;
final cosT = math.cos(theta);
final oneMinusCosT = 1 - cosT;
final sinT = math.sin(theta);
// Build the matrix entries element by element.
_m11 = u2 + (v2 + w2) * cosT;
_m12 = u * v * oneMinusCosT - w * sinT;
_m13 = u * w * oneMinusCosT + v * sinT;
_m14 = (a * (v2 + w2) - u * (b * v + c * w)) * oneMinusCosT +
(b * w - c * v) * sinT;
_m21 = u * v * oneMinusCosT + w * sinT;
_m22 = v2 + (u2 + w2) * cosT;
_m23 = v * w * oneMinusCosT - u * sinT;
_m24 = (b * (u2 + w2) - v * (a * u + c * w)) * oneMinusCosT +
(c * u - a * w) * sinT;
_m31 = u * w * oneMinusCosT - v * sinT;
_m32 = v * w * oneMinusCosT + u * sinT;
_m33 = w2 + (u2 + v2) * cosT;
_m34 = (c * (u2 + v2) - w * (a * u + b * v)) * oneMinusCosT +
(a * v - b * u) * sinT;
}