Exemplo n.º 1
0
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <returns>A new <see cref="Vector3F"/> instance containing the result.</returns>
 public static Vector3F Transform(Matrix3F matrix, Vector3F vector)
 {
     return(new Vector3F(
                (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)));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Transposes a matrix.
        /// </summary>
        /// <param name="m">A <see cref="Matrix3F"/> instance.</param>
        /// <returns>A new <see cref="Matrix3F"/> instance containing the transposed matrix.</returns>
        public static Matrix3F Transpose(Matrix3F m)
        {
            Matrix3F t = new Matrix3F(m);

            t.Transpose();
            return(t);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F Add(Matrix3F a, Matrix3F b)
 {
     return(new Matrix3F(
                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
                ));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F Add(Matrix3F a, float s)
 {
     return(new Matrix3F(
                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
                ));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance to subtract from.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance to subtract.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
 public static Matrix3F Subtract(Matrix3F a, Matrix3F b)
 {
     return(new Matrix3F(
                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
                ));
 }
Exemplo n.º 6
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 public static Matrix3F Subtract(Matrix3F a, float s)
 {
     return(new Matrix3F(
                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
                ));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Returns a value indicating whether this instance is equal to
 /// the specified object.
 /// </summary>
 /// <param name="obj">An object to compare to this instance.</param>
 /// <returns><see langword="true"/> if <paramref name="obj"/> is a <see cref="Matrix3F"/> and has the same values as this instance; otherwise, <see langword="false"/>.</returns>
 public override bool Equals(object obj)
 {
     if (obj is Matrix3F)
     {
         Matrix3F m = (Matrix3F)obj;
         return
             ((_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));
     }
     return(false);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Adds two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Add(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Subtracts a scalar from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Subtract(Matrix3F a, float s, ref Matrix3F 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;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Multiplies two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Multiply(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 11
0
        /// <summary>
        /// Subtracts a matrix from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance to subtract from.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance to subtract.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
        public static void Subtract(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Adds a matrix and a scalar and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Add(Matrix3F a, float s, ref Matrix3F 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;
        }
Exemplo n.º 13
0
        /// <summary>
        /// Multiplies two matrices.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <returns>A new <see cref="Matrix3F"/> instance containing the result.</returns>
        public static Matrix3F Multiply(Matrix3F a, Matrix3F b)
        {
            return(new Matrix3F(
                       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
                       ));
        }
Exemplo n.º 14
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="Matrix3F"/> instance containing the result Minor.</returns>
        public Matrix3F Minor(int row, int column)
        {
            int      r      = 0;
            Matrix3F result = new Matrix3F();

            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);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Matrix3F"/> class using a given matrix.
 /// </summary>
 public Matrix3F(Matrix3F 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;
 }
Exemplo n.º 16
0
        /// <summary>
        /// Multiplies two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Multiply(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 17
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance to subtract from.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance to subtract.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
 public static Matrix3F Subtract(Matrix3F a, Matrix3F b)
 {
     return new Matrix3F(
         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
         );
 }
Exemplo n.º 18
0
        /// <summary>
        /// Subtracts a matrix from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance to subtract from.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance to subtract.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
        public static void Subtract(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 19
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F Add(Matrix3F a, float s)
 {
     return new Matrix3F(
         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
         );
 }
Exemplo n.º 20
0
        /// <summary>
        /// Adds two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Add(Matrix3F a, Matrix3F b, ref Matrix3F 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;
        }
Exemplo n.º 21
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="Matrix3F"/> instance containing the result Minor.</returns>
 public Matrix3F Minor(int row, int column)
 {
     int r = 0;
     Matrix3F result = new Matrix3F();
     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;
 }
Exemplo n.º 22
0
 /// <summary>
 /// Transposes a matrix.
 /// </summary>
 /// <param name="m">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the transposed matrix.</returns>
 public static Matrix3F Transpose(Matrix3F m)
 {
     Matrix3F t = new Matrix3F(m);
     t.Transpose();
     return t;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <param name="result">A <see cref="Vector3F"/> instance to hold the result.</param>
 public static void Transform(Matrix3F matrix, Vector3F vector, ref Vector3F 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);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <returns>A new <see cref="Vector3F"/> instance containing the result.</returns>
 public static Vector3F Transform(Matrix3F matrix, Vector3F vector)
 {
     return new Vector3F(
         (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));
 }
Exemplo n.º 25
0
        /// <summary>
        /// Subtracts a scalar from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Subtract(Matrix3F a, float s, ref Matrix3F 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;
        }
Exemplo n.º 26
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F operator+(Matrix3F a, Matrix3F b)
 {
     return(Matrix3F.Add(a, b));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 public static Matrix3F operator-(Matrix3F a, Matrix3F b)
 {
     return(Matrix3F.Subtract(a, b));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <param name="result">A <see cref="Vector3F"/> instance to hold the result.</param>
 public static void Transform(Matrix3F matrix, Vector3F vector, ref Vector3F 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);
 }
Exemplo n.º 29
0
        /// <summary>
        /// Multiplies two matrices.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
        /// <returns>A new <see cref="Matrix3F"/> instance containing the result.</returns>
        public static Matrix3F Multiply(Matrix3F a, Matrix3F b)
        {
            return new Matrix3F(
                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
                );
        }
Exemplo n.º 30
0
 /// <summary>
 /// Multiplies two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the result.</returns>
 public static Matrix3F operator*(Matrix3F a, Matrix3F b)
 {
     return(Matrix3F.Multiply(a, b));
 }
Exemplo n.º 31
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 public static Matrix3F Subtract(Matrix3F a, float s)
 {
     return new Matrix3F(
         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
         );
 }
Exemplo n.º 32
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F operator+(float s, Matrix3F a)
 {
     return(Matrix3F.Add(a, s));
 }
Exemplo n.º 33
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix3F"/> instance.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the sum.</returns>
 public static Matrix3F Add(Matrix3F a, Matrix3F b)
 {
     return new Matrix3F(
         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
         );
 }
Exemplo n.º 34
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix3F"/> instance containing the difference.</returns>
 public static Matrix3F operator-(Matrix3F a, float s)
 {
     return(Matrix3F.Subtract(a, s));
 }
Exemplo n.º 35
0
        /// <summary>
        /// Adds a matrix and a scalar and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix3F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix3F"/> instance to hold the result.</param>
        public static void Add(Matrix3F a, float s, ref Matrix3F 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;
        }
Exemplo n.º 36
0
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix3F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector3F"/> instance.</param>
 /// <returns>A new <see cref="Vector3F"/> instance containing the result.</returns>
 public static Vector3F operator*(Matrix3F matrix, Vector3F vector)
 {
     return(Matrix3F.Transform(matrix, vector));
 }
Exemplo n.º 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Matrix3F"/> class using a given matrix.
 /// </summary>
 public Matrix3F(Matrix3F 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;
 }