Ejemplo n.º 1
0
        /// <summary>
        ///  This function checks the equality between two values <see cref="xyz"/>
        ///  This is to avoid errors at the computational accuracy with doubles.
        ///  If their distance of the coordinates is less than <see cref="Utils.epsilon"/> equality is done
        ///  </summary>
        ///  <param name="obj">Matrx value</param>
        ///  <returns> returns true, if they are nearly equal</returns>

        public override bool Equals(object obj)
        {
            if (obj is Matrix)
            {
                Base B = this.toBase();
                Base A = ((Matrix)obj).toBase();
                return(B.Equals(A));
            }

            else

            if (obj is Double[])
            {
                double[] a = (double[])obj;
                if (a.Length != 16)
                {
                    return(false);
                }
                if (!Utils.Equals(a[0], a00))
                {
                    return(false);
                }
                if (!Utils.Equals(a[1], a01))
                {
                    return(false);
                }
                if (!Utils.Equals(a[2], a02))
                {
                    return(false);
                }
                if (!Utils.Equals(a[3], a03))
                {
                    return(false);
                }

                if (!Utils.Equals(a[4], a10))
                {
                    return(false);
                }
                if (!Utils.Equals(a[5], a11))
                {
                    return(false);
                }
                if (!Utils.Equals(a[6], a12))
                {
                    return(false);
                }
                if (!Utils.Equals(a[7], a13))
                {
                    return(false);
                }

                if (!Utils.Equals(a[8], a20))
                {
                    return(false);
                }
                if (!Utils.Equals(a[9], a21))
                {
                    return(false);
                }
                if (!Utils.Equals(a[10], a22))
                {
                    return(false);
                }
                if (!Utils.Equals(a[11], a23))
                {
                    return(false);
                }

                if (!Utils.Equals(a[12], a30))
                {
                    return(false);
                }
                if (!Utils.Equals(a[13], a31))
                {
                    return(false);
                }
                if (!Utils.Equals(a[14], a32))
                {
                    return(false);
                }
                if (!Utils.Equals(a[15], a33))
                {
                    return(false);
                }
                return(true);
            }

            return(base.Equals(obj));
        }