Example #1
0
        /// <summary> Add two matricies
        /// 
        /// </summary>
        /// <param name="A">The first matrix
        /// </param>
        /// <param name="B">The second matrix
        /// </param>
        /// <returns> A newly created matrix containing the result
        /// </returns>
        public static Matrix2f Add(Matrix2f A, Matrix2f B)
        {
            Vector2f temp1 = new Vector2f(A.col1);
            temp1.Add(B.col1);
            Vector2f temp2 = new Vector2f(A.col2);
            temp2.Add(B.col2);

            return new Matrix2f(temp1, temp2);
        }
Example #2
0
        /// <summary> Transpose the Invert
        /// 
        /// </summary>
        /// <returns> A newly created matrix containing the Invert of this matrix
        /// </returns>
        public virtual Matrix2f Invert()
        {
            float a = col1.x, b = col2.x, c = col1.y, d = col2.y;
            Matrix2f B = new Matrix2f();

            float det = a * d - b * c;
            if (det == 0.0f)
            {
                throw new System.SystemException("Matrix2f: Invert() - determinate is zero!");
            }

            det = 1.0f / det;
            B.col1.x = det * d; B.col2.x = (- det) * b;
            B.col1.y = (- det) * c; B.col2.y = det * a;
            return B;
        }
Example #3
0
 /// <summary> Multiple two matricies
 /// 
 /// </summary>
 /// <param name="A">The first matrix
 /// </param>
 /// <param name="B">The second matrix
 /// </param>
 /// <returns> A newly created matrix containing the result
 /// </returns>
 public static Matrix2f Mul(Matrix2f A, Matrix2f B)
 {
     return new Matrix2f(Mul(A, B.col1), Mul(A, B.col2));
 }
Example #4
0
 /// <summary> Create the absolute version of a matrix
 /// 
 /// </summary>
 /// <param name="A">The matrix to make absolute
 /// </param>
 /// <returns> A newly created absolute matrix
 /// </returns>
 public static Matrix2f Abs(Matrix2f A)
 {
     return new Matrix2f(Abs(A.col1), Abs(A.col2));
 }
Example #5
0
 /// <summary> Multiply a matrix by a vector
 /// 
 /// </summary>
 /// <param name="A">The matrix to be multiplied
 /// </param>
 /// <param name="v">The vector to multiple by
 /// </param>
 /// <returns> A newly created vector containing the resultant vector
 /// </returns>
 public static Vector2f Mul(Matrix2f A, ROVector2f v)
 {
     return new Vector2f(A.col1.x * v.X + A.col2.x * v.Y, A.col1.y * v.X + A.col2.y * v.Y);
 }