Ejemplo n.º 1
0
 /// <summary>
 /// Creates a 4 x 4 matrix where all the values represent an identity matrix except
 /// that the bottom row has been set to be the translation values.  The result is
 /// that if a 3D vector is transformed by this matrix, the last row will
 /// control the translation terms.
 /// </summary>
 /// <param name="x">The translation in the x direction</param>
 /// <param name="y">The translation in the y direction</param>
 /// <param name="z">The translation in the z direction</param>
 /// <returns>The translation matrix</returns>
 public static Matrix4 Translation(double x, double y, double z)
 {
     Matrix4 result = new Matrix4();
     double[,] vals = result.Values;
     vals[3, 0] = x;
     vals[3, 1] = y;
     vals[3, 2] = z;
     return result;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a 4 x 4 matrix that can be used to rotate a 3D vector about the Z axis.
 /// </summary>
 /// <param name="degrees">The counter-clockwise angle of rotation when looking at the origin from the positive axis</param>
 /// <returns>A 4x4 rotation matrix</returns>
 public static Matrix4 RotationZ(double degrees)
 {
     Matrix4 result = new Matrix4();
     double rad = degrees * Math.PI / 180;
     double[,] vals = result.Values;
     vals[0, 0] = Math.Cos(rad);
     vals[0, 1] = -Math.Sin(rad);
     vals[1, 0] = Math.Sin(rad);
     vals[1, 1] = Math.Cos(rad);
     return result;
 }