/// <summary>
 /// Transposes a matrix.
 /// </summary>
 /// <param name="m">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the transposed matrix.</returns>
 public static Matrix3D Transpose(Matrix3D m)
 {
     Matrix3D t = new Matrix3D(m);
     t.Transpose();
     return t;
 }
예제 #2
0
		/// <summary>
		/// Build a 3x3 matrix from from the current matrix without the given row and column.
		/// </summary>
		/// <param name="row">The row to remove.</param>
		/// <param name="column">The column to remove.</param>
		/// <returns>A <see cref="Matrix3D"/> instance containing the result Minor.</returns>
		public Matrix3D Minor(int row, int column) 
		{
			int r = 0;
			Matrix3D result = new Matrix3D();
			for (int iRow = 0; iRow < 4; iRow++) 
			{
				int c = 0;
				if (iRow != row) 
				{
					for (int iCol = 0; iCol < 4; iCol++) 
					{
						if (iCol != column) 
						{
							result[r,c] = this[iRow, iCol];
							c++;
						}
					}
					r++;
				}
			}
			return result;
		}
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3D"/> instance.</param>
 /// <returns>A new <see cref="Vector3D"/> instance containing the result.</returns>
 public static Vector3D Transform(Matrix3D matrix, Vector3D vector)
 {
     return new Vector3D(
         (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z),
         (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z),
         (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z));
 }
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3D"/> instance.</param>
 /// <param name="result">A <see cref="Vector3D"/> instance to hold the result.</param>
 public static void Transform(Matrix3D matrix, Vector3D vector, ref Vector3D result)
 {
     result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z);
     result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z);
     result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z);
 }
        /// <summary>
        /// Subtracts a matrix from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance to subtract from.</param>
        /// <param name="b">A <see cref="Matrix3D"/> instance to subtract.</param>
        /// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
        /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
        public static void Subtract(Matrix3D a, Matrix3D b, ref Matrix3D result)
        {
            result.M11 = a.M11 - b.M11;
            result.M12 = a.M12 - b.M12;
            result.M13 = a.M13 - b.M13;

            result.M21 = a.M21 - b.M21;
            result.M22 = a.M22 - b.M22;
            result.M23 = a.M23 - b.M23;

            result.M31 = a.M31 - b.M31;
            result.M32 = a.M32 - b.M32;
            result.M33 = a.M33 - b.M33;
        }
        /// <summary>
        /// Subtracts a scalar from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
        public static void Subtract(Matrix3D a, double s, ref Matrix3D result)
        {
            result.M11 = a.M11 - s;
            result.M12 = a.M12 - s;
            result.M13 = a.M13 - s;

            result.M21 = a.M21 - s;
            result.M22 = a.M22 - s;
            result.M23 = a.M23 - s;

            result.M31 = a.M31 - s;
            result.M32 = a.M32 - s;
            result.M33 = a.M33 - s;
        }
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance to subtract from.</param>
 /// <param name="b">A <see cref="Matrix3D"/> instance to subtract.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
 public static Matrix3D Subtract(Matrix3D a, Matrix3D b)
 {
     return new Matrix3D(
         a.M11 - b.M11, a.M12 - b.M12, a.M13 - b.M13,
         a.M21 - b.M21, a.M22 - b.M22, a.M23 - b.M23,
         a.M31 - b.M31, a.M32 - b.M32, a.M33 - b.M33
         );
 }
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the difference.</returns>
 public static Matrix3D Subtract(Matrix3D a, double s)
 {
     return new Matrix3D(
         a.M11 - s, a.M12 - s, a.M13 - s,
         a.M21 - s, a.M22 - s, a.M23 - s,
         a.M31 - s, a.M32 - s, a.M33 - s
         );
 }
        /// <summary>
        /// Multiplies two matrices.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
        /// <returns>A new <see cref="Matrix3D"/> instance containing the result.</returns>
        public static Matrix3D Multiply(Matrix3D a, Matrix3D b)
        {
            return new Matrix3D(
                a.M11 * b.M11 + a.M12 * b.M21 + a.M13 * b.M31,
                a.M11 * b.M12 + a.M12 * b.M22 + a.M13 * b.M32,
                a.M11 * b.M13 + a.M12 * b.M23 + a.M13 * b.M33,

                a.M21 * b.M11 + a.M22 * b.M21 + a.M23 * b.M31,
                a.M21 * b.M12 + a.M22 * b.M22 + a.M23 * b.M32,
                a.M21 * b.M13 + a.M22 * b.M23 + a.M23 * b.M33,

                a.M31 * b.M11 + a.M32 * b.M21 + a.M33 * b.M31,
                a.M31 * b.M12 + a.M32 * b.M22 + a.M33 * b.M32,
                a.M31 * b.M13 + a.M32 * b.M23 + a.M33 * b.M33
                );
        }
예제 #10
0
        /// <summary>
        /// Multiplies two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
        public static void Multiply(Matrix3D a, Matrix3D b, ref Matrix3D result)
        {
            result.M11 = a.M11 * b.M11 + a.M12 * b.M21 + a.M13 * b.M31;
            result.M12 = a.M11 * b.M12 + a.M12 * b.M22 + a.M13 * b.M32;
            result.M13 = a.M11 * b.M13 + a.M12 * b.M23 + a.M13 * b.M33;

            result.M21 = a.M21 * b.M11 + a.M22 * b.M21 + a.M23 * b.M31;
            result.M22 = a.M21 * b.M12 + a.M22 * b.M22 + a.M23 * b.M32;
            result.M23 = a.M21 * b.M13 + a.M22 * b.M23 + a.M23 * b.M33;

            result.M31 = a.M31 * b.M11 + a.M32 * b.M21 + a.M33 * b.M31;
            result.M32 = a.M31 * b.M12 + a.M32 * b.M22 + a.M33 * b.M32;
            result.M33 = a.M31 * b.M13 + a.M32 * b.M23 + a.M33 * b.M33;
        }
예제 #11
0
        /// <summary>
        /// Adds a matrix and a scalar and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
        public static void Add(Matrix3D a, double s, ref Matrix3D result)
        {
            result.M11 = a.M11 + s;
            result.M12 = a.M12 + s;
            result.M13 = a.M13 + s;

            result.M21 = a.M21 + s;
            result.M22 = a.M22 + s;
            result.M23 = a.M23 + s;

            result.M31 = a.M31 + s;
            result.M32 = a.M32 + s;
            result.M33 = a.M33 + s;
        }
예제 #12
0
        /// <summary>
        /// Adds two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3D"/> instance to hold the result.</param>
        public static void Add(Matrix3D a, Matrix3D b, ref Matrix3D result)
        {
            result.M11 = a.M11 + b.M11;
            result.M12 = a.M12 + b.M12;
            result.M13 = a.M13 + b.M13;

            result.M21 = a.M21 + b.M21;
            result.M22 = a.M22 + b.M22;
            result.M23 = a.M23 + b.M23;

            result.M31 = a.M31 + b.M31;
            result.M32 = a.M32 + b.M32;
            result.M33 = a.M33 + b.M33;
        }
예제 #13
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D Add(Matrix3D a, double s)
 {
     return new Matrix3D(
         a.M11 + s, a.M12 + s, a.M13 + s,
         a.M21 + s, a.M22 + s, a.M23 + s,
         a.M31 + s, a.M32 + s, a.M33 + s
         );
 }
예제 #14
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3D"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3D"/> instance.</param>
 /// <returns>A new <see cref="Matrix3D"/> instance containing the sum.</returns>
 public static Matrix3D Add(Matrix3D a, Matrix3D b)
 {
     return new Matrix3D(
         a.M11 + b.M11, a.M12 + b.M12, a.M13 + b.M13,
         a.M21 + b.M21, a.M22 + b.M22, a.M23 + b.M23,
         a.M31 + b.M31, a.M32 + b.M32, a.M33 + b.M33
         );
 }
예제 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Matrix3D"/> class using a given matrix.
 /// </summary>
 public Matrix3D(Matrix3D m)
 {
     _m11 = m.M11; _m12 = m.M12; _m13 = m.M13;
     _m21 = m.M21; _m22 = m.M22; _m23 = m.M23;
     _m31 = m.M31; _m32 = m.M32; _m33 = m.M33;
 }