Exemplo n.º 1
0
        /// <summary>
        /// Subtract two matrices.
        /// </summary>
        public static Matrix2x2f operator -(Matrix2x2f m1, Matrix2x2f m2)
        {
            Matrix2x2f kSum = new Matrix2x2f();

            kSum.m00 = m1.m00 - m2.m00;
            kSum.m10 = m1.m10 - m2.m10;
            kSum.m01 = m1.m01 - m2.m01;
            kSum.m11 = m1.m11 - m2.m11;
            return(kSum);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Are these matrices equal.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (!(obj is Matrix2x2f))
            {
                return(false);
            }

            Matrix2x2f mat = (Matrix2x2f)obj;

            return(this == mat);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Multiply a matrix by a scalar.
        /// </summary>
        public static Matrix2x2f operator *(float s, Matrix2x2f m)
        {
            Matrix2x2f kProd = new Matrix2x2f();

            kProd.m00 = m.m00 * s;
            kProd.m10 = m.m10 * s;
            kProd.m01 = m.m01 * s;
            kProd.m11 = m.m11 * s;

            return(kProd);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Multiply two matrices.
        /// </summary>
        public static Matrix2x2f operator *(Matrix2x2f m1, Matrix2x2f m2)
        {
            Matrix2x2f kProd = new Matrix2x2f();

            kProd.m00 = m1.m00 * m2.m00 + m1.m01 * m2.m10;
            kProd.m10 = m1.m10 * m2.m00 + m1.m11 * m2.m10;
            kProd.m01 = m1.m00 * m2.m01 + m1.m01 * m2.m11;
            kProd.m11 = m1.m10 * m2.m01 + m1.m11 * m2.m11;

            return(kProd);
        }
Exemplo n.º 5
0
        /// <summary>
        /// The Inverse of the matrix copied into mInv.
        /// Returns false if the matrix has no inverse.
        /// A matrix multipled by its inverse is the idenity.
        /// </summary>
        public bool TryInverse(ref Matrix2x2f mInv)
        {
            float det = Determinant;

            if (FMath.IsZero(det))
            {
                return(false);
            }

            float invDet = 1.0f / det;

            mInv.m00 = m11 * invDet;
            mInv.m01 = -m01 * invDet;
            mInv.m10 = -m10 * invDet;
            mInv.m11 = m00 * invDet;
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Are these matrices equal.
        /// </summary>
        public bool EqualsWithError(Matrix2x2f m, float eps)
        {
            if (Math.Abs(m00 - m.m00) > eps)
            {
                return(false);
            }
            if (Math.Abs(m10 - m.m10) > eps)
            {
                return(false);
            }
            if (Math.Abs(m01 - m.m01) > eps)
            {
                return(false);
            }
            if (Math.Abs(m11 - m.m11) > eps)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Are these matrices equal.
 /// </summary>
 public bool Equals(Matrix2x2f mat)
 {
     return(this == mat);
 }