Exemplo n.º 1
0
        /// <summary>
        /// Are these matrices equal.
        /// </summary>
        public override bool Equals(object obj)
        {
            if (!(obj is Matrix2x2d))
            {
                return(false);
            }

            Matrix2x2d mat = (Matrix2x2d)obj;

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

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

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

            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.º 4
0
        /// <summary>
        /// Add two matrices.
        /// </summary>
        public static Matrix2x2d operator +(Matrix2x2d m1, Matrix2x2d m2)
        {
            Matrix2x2d kSum = new Matrix2x2d();

            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.º 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 Matrix2x2d mInv)
        {
            double det = Determinant;

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

            double invDet = 1.0 / 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(Matrix2x2d m, double 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(Matrix2x2d mat)
 {
     return(this == mat);
 }