The cells in a rotation matrix are the sines and cosines of the angle of rotation. In the Matrix3 right-handed coordinate system, positive angles move in a counterclockwise direction, when looking down an axis from positive to negative. In the diagram below, the cones along the XYZ axes point in the positive direction, and the cones in the circles around each axis point in the positive direction of rotation.
The matrices for rotation about the three axes are shown below. In each case a represents the angle of rotation in radians:
There are global functions in the 3ds Max API to create these rotation matrices and to apply rotation to existing matrices. Several of these are given below:
Matrix3 RotateXMatrix(floatangle);
Builds a new matrix for use as a X rotation transformation. The angle is specified in radians.
Matrix3 RotateYMatrix(floatangle);
Builds a new matrix for use as a Y rotation transformation.
Matrix3 RotateZMatrix(floatangle);
Builds a new matrix for use as a Z rotation transformation.
Developer can also remove the rotation from a given matrix using the Matrix3 method:
void NoRot();
This method nulls the rotation portion of the matrix.
Creating Quaternions from Rotation Matrices
A quaternion can be created from a rotation matrix. By passing the Matrix3 to the constructor of the Quat, its rotation values are used to initialize the quaternion. The following code shows an example of this. It takes a Point3v and creates a quaternion based on the angles stored after snapping them using the current 3ds Max angle snap settings.
Matrix3 mat; mat.IdentityMatrix(); mat.RotateX(ip->SnapAngle(v.x)); mat.RotateY(ip->SnapAngle(v.y)); mat.RotateZ(ip->SnapAngle(v.z)); Quat q(mat);