// theta is in degrees public static GraphicsMatrix GetRotationMatrix(double thetaX, double thetaY, double thetaZ) { double c = Math.PI / 180; double radX = c * thetaX; double radY = c * thetaY; double radZ = c * thetaZ; GraphicsMatrix x = new GraphicsMatrix(new double[4, 4] { { 1, 0, 0, 0 }, { 0, Math.Cos(radX), Math.Sin(radX), 0 }, { 0, -1 * Math.Sin(radX), Math.Cos(radX), 0 }, { 0, 0, 0, 1 } }); GraphicsMatrix y = new GraphicsMatrix(new double [4, 4] { { Math.Cos(radY), 0, Math.Sin(radY), 0 }, { 0, 1, 0, 0 }, { -1 * Math.Sin(radY), 0, Math.Cos(radY), 0 }, { 0, 0, 0, 1 } }); GraphicsMatrix z = new GraphicsMatrix(new double[4, 4] { { Math.Cos(radZ), Math.Sin(radZ), 0, 0 }, { -1 * Math.Sin(radZ), Math.Cos(radZ), 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 } }); y.Multiply(x); z.Multiply(x); return(x); }
public void Rotate(GraphicsMatrix rotationMatrix) { rotationMatrix.Multiply(this); }