July 2007
Intermediate to advanced
448 pages
13h 39m
English
If you want to write code yourself that performs rotations, you can use the Quaternion structure with the rotation formulas I've shown you. For example, suppose you want to rotate the variable point of type Point3D by angle degrees around the axis vector. You first need to get a rotation quaternion and its conjugate:
Quaternion qRotate = new Quaternion(axis, angle); Quaternion qConjugate = qRotate; qConjugate.Conjugate();
Now convert the Point3D object to a pure quaternion:
Quaternion qPoint = new Quaternion(point.X, point.Y, point.Z, 0);
Multiply that point by the rotation quaternion on the left and its conjugate on the right:
Quaternion qRotatedPoint = qRotate * qPoint * qConjugate;
And convert back to a Point3D:
pointRotated ...
Read now
Unlock full access