Ejemplo n.º 1
0
 /// <summary>
 /// Transposes a matrix.
 /// </summary>
 /// <param name="m">A <see cref="Matrix2F"/> instance.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the transposed matrix.</returns>
 public static Matrix2F Transpose(Matrix2F m)
 {
     Matrix2F t = new Matrix2F(m);
     t.Transpose();
     return t;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Transforms a given vector by a matrix.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector2F"/> instance.</param>
 /// <returns>A new <see cref="Vector2F"/> instance containing the result.</returns>
 public static Vector2F Transform(Matrix2F matrix, Vector2F vector)
 {
     return new Vector2F(
         (matrix.M11 * vector.X) + (matrix.M12 * vector.Y),
         (matrix.M21 * vector.X) + (matrix.M22 * vector.Y));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Transforms a given vector by a matrix and put the result in a vector.
 /// </summary>
 /// <param name="matrix">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="vector">A <see cref="Vector2F"/> instance.</param>
 /// <param name="result">A <see cref="Vector2F"/> instance to hold the result.</param>
 public static void Transform(Matrix2F matrix, Vector2F vector, ref Vector2F result)
 {
     result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y);
     result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Subtracts a matrix from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix2F"/> instance to subtract from.</param>
        /// <param name="b">A <see cref="Matrix2F"/> instance to subtract.</param>
        /// <param name="result">A <see cref="Matrix2F"/> instance to hold the result.</param>
        /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
        public static void Subtract(Matrix2F a, Matrix2F b, ref Matrix2F result)
        {
            result.M11 = a.M11 - b.M11;
            result.M12 = a.M12 - b.M12;

            result.M21 = a.M21 - b.M21;
            result.M22 = a.M22 - b.M22;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Subtracts a scalar from a matrix and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix2F"/> instance to hold the result.</param>
        public static void Subtract(Matrix2F a, float s, ref Matrix2F result)
        {
            result.M11 = a.M11 - s;
            result.M12 = a.M12 - s;

            result.M21 = a.M21 - s;
            result.M22 = a.M22 - s;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Subtracts a matrix from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance to subtract from.</param>
 /// <param name="b">A <see cref="Matrix2F"/> instance to subtract.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the difference.</returns>
 /// <remarks>result[x][y] = a[x][y] - b[x][y]</remarks>
 public static Matrix2F Subtract(Matrix2F a, Matrix2F b)
 {
     return new Matrix2F(
         a.M11 - b.M11, a.M12 - b.M12,
         a.M21 - b.M21, a.M22 - b.M22
         );
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Subtracts a scalar from a matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the difference.</returns>
 public static Matrix2F Subtract(Matrix2F a, float s)
 {
     return new Matrix2F(
         a.M11 - s, a.M12 - s,
         a.M21 - s, a.M22 - s
         );
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Multiplies two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix2F"/> instance.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the result.</returns>
 public static Matrix2F Multiply(Matrix2F a, Matrix2F b)
 {
     return new Matrix2F(
         a.M11 * b.M11 + a.M12 * b.M21,
         a.M11 * b.M12 + a.M12 * b.M22,
         a.M11 * b.M12 + a.M12 * b.M22,
         a.M21 * b.M12 + a.M22 * b.M22
         );
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Multiplies two matrices and put the result in a third matrix.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="result">A <see cref="Matrix2F"/> instance to hold the result.</param>
 public static void Multiply(Matrix2F a, Matrix2F b, ref Matrix2F result)
 {
     result.M11 = a.M11 * b.M11 + a.M12 * b.M21;
     result.M12 = a.M11 * b.M12 + a.M12 * b.M22;
     result.M21 = a.M11 * b.M12 + a.M12 * b.M22;
     result.M22 = a.M21 * b.M12 + a.M22 * b.M22;
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds a matrix and a scalar and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
        /// <param name="s">A scalar.</param>
        /// <param name="result">A <see cref="Matrix2F"/> instance to hold the result.</param>
        public static void Add(Matrix2F a, float s, ref Matrix2F result)
        {
            result.M11 = a.M11 + s;
            result.M12 = a.M12 + s;

            result.M21 = a.M21 + s;
            result.M22 = a.M22 + s;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds two matrices and put the result in a third matrix.
        /// </summary>
        /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
        /// <param name="b">A <see cref="Matrix2F"/> instance.</param>
        /// <param name="result">A <see cref="Matrix2F"/> instance to hold the result.</param>
        public static void Add(Matrix2F a, Matrix2F b, ref Matrix2F result)
        {
            result.M11 = a.M11 + b.M11;
            result.M12 = a.M12 + b.M12;

            result.M21 = a.M21 + b.M21;
            result.M22 = a.M22 + b.M22;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Adds a matrix and a scalar.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the sum.</returns>
 public static Matrix2F Add(Matrix2F a, float s)
 {
     return new Matrix2F(
         a.M11 + s, a.M12 + s,
         a.M21 + s, a.M22 + s
         );
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Adds two matrices.
 /// </summary>
 /// <param name="a">A <see cref="Matrix2F"/> instance.</param>
 /// <param name="b">A <see cref="Matrix2F"/> instance.</param>
 /// <returns>A new <see cref="Matrix2F"/> instance containing the sum.</returns>
 public static Matrix2F Add(Matrix2F a, Matrix2F b)
 {
     return new Matrix2F(
         a.M11 + b.M11, a.M12 + b.M12,
         a.M21 + b.M21, a.M22 + b.M22
         );
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Matrix2F"/> class using a given matrix.
 /// </summary>
 public Matrix2F(Matrix2F m)
 {
     _m11 = m.M11; _m12 = m.M12;
     _m21 = m.M21; _m22 = m.M22;
 }