Пример #1
0
        /// <summary>
        /// Subtract two matrices.
        /// </summary>
        public static Matrix3x3f operator -(Matrix3x3f m1, Matrix3x3f m2)
        {
            Matrix3x3f kSum = new Matrix3x3f();

            kSum.m00 = m1.m00 - m2.m00;
            kSum.m01 = m1.m01 - m2.m01;
            kSum.m02 = m1.m02 - m2.m02;

            kSum.m10 = m1.m10 - m2.m10;
            kSum.m11 = m1.m11 - m2.m11;
            kSum.m12 = m1.m12 - m2.m12;

            kSum.m20 = m1.m20 - m2.m20;
            kSum.m21 = m1.m21 - m2.m21;
            kSum.m22 = m1.m22 - m2.m22;
            return(kSum);
        }
Пример #2
0
        /// <summary>
        /// Multiply a matrix by a scalar.
        /// </summary>
        public static Matrix3x3f operator *(float s, Matrix3x3f m1)
        {
            Matrix3x3f kProd = new Matrix3x3f();

            kProd.m00 = m1.m00 * s;
            kProd.m01 = m1.m01 * s;
            kProd.m02 = m1.m02 * s;

            kProd.m10 = m1.m10 * s;
            kProd.m11 = m1.m11 * s;
            kProd.m12 = m1.m12 * s;

            kProd.m20 = m1.m20 * s;
            kProd.m21 = m1.m21 * s;
            kProd.m22 = m1.m22 * s;

            return(kProd);
        }
Пример #3
0
        /// <summary>
        /// Multiply two matrices.
        /// </summary>
        public static Matrix3x3f operator *(Matrix3x3f m1, Matrix3x3f m2)
        {
            Matrix3x3f kProd = new Matrix3x3f();

            kProd.m00 = m1.m00 * m2.m00 + m1.m01 * m2.m10 + m1.m02 * m2.m20;
            kProd.m01 = m1.m00 * m2.m01 + m1.m01 * m2.m11 + m1.m02 * m2.m21;
            kProd.m02 = m1.m00 * m2.m02 + m1.m01 * m2.m12 + m1.m02 * m2.m22;

            kProd.m10 = m1.m10 * m2.m00 + m1.m11 * m2.m10 + m1.m12 * m2.m20;
            kProd.m11 = m1.m10 * m2.m01 + m1.m11 * m2.m11 + m1.m12 * m2.m21;
            kProd.m12 = m1.m10 * m2.m02 + m1.m11 * m2.m12 + m1.m12 * m2.m22;

            kProd.m20 = m1.m20 * m2.m00 + m1.m21 * m2.m10 + m1.m22 * m2.m20;
            kProd.m21 = m1.m20 * m2.m01 + m1.m21 * m2.m11 + m1.m22 * m2.m21;
            kProd.m22 = m1.m20 * m2.m02 + m1.m21 * m2.m12 + m1.m22 * m2.m22;

            return(kProd);
        }
Пример #4
0
        /// <summary>
        /// Add two matrices.
        /// </summary>
        public static Matrix3x3f operator +(Matrix3x3f m1, Matrix3x3f m2)
        {
            Matrix3x3f kSum = new Matrix3x3f();

            kSum.m00 = m1.m00 + m2.m00;
            kSum.m01 = m1.m01 + m2.m01;
            kSum.m02 = m1.m02 + m2.m02;

            kSum.m10 = m1.m10 + m2.m10;
            kSum.m11 = m1.m11 + m2.m11;
            kSum.m12 = m1.m12 + m2.m12;

            kSum.m20 = m1.m20 + m2.m20;
            kSum.m21 = m1.m21 + m2.m21;
            kSum.m22 = m1.m22 + m2.m22;

            return(kSum);
        }
Пример #5
0
        /// <summary>
        /// Are these matrices equal.
        /// </summary>
        public bool EqualsWithError(Matrix3x3f m, float eps)
        {
            if (Math.Abs(m00 - m.m00) > eps)
            {
                return(false);
            }
            if (Math.Abs(m10 - m.m10) > eps)
            {
                return(false);
            }
            if (Math.Abs(m20 - m.m20) > eps)
            {
                return(false);
            }

            if (Math.Abs(m01 - m.m01) > eps)
            {
                return(false);
            }
            if (Math.Abs(m11 - m.m11) > eps)
            {
                return(false);
            }
            if (Math.Abs(m21 - m.m21) > eps)
            {
                return(false);
            }

            if (Math.Abs(m02 - m.m02) > eps)
            {
                return(false);
            }
            if (Math.Abs(m12 - m.m12) > eps)
            {
                return(false);
            }
            if (Math.Abs(m22 - m.m22) > eps)
            {
                return(false);
            }

            return(true);
        }
Пример #6
0
 /// <summary>
 /// Are these matrices equal.
 /// </summary>
 public bool Equals(Matrix3x3f mat)
 {
     return(this == mat);
 }