Example #1
0
 public override int GetHashCode()
 {
     // Perform field-by-field XOR of HashCodes
     return(M11.GetHashCode() ^
            M12.GetHashCode() ^
            M13.GetHashCode() ^
            M14.GetHashCode() ^
            M21.GetHashCode() ^
            M22.GetHashCode() ^
            M23.GetHashCode() ^
            M24.GetHashCode() ^
            M31.GetHashCode() ^
            M32.GetHashCode() ^
            M33.GetHashCode() ^
            M34.GetHashCode() ^
            OffsetX.GetHashCode() ^
            OffsetY.GetHashCode() ^
            OffsetZ.GetHashCode() ^
            M44.GetHashCode());
 }
Example #2
0
        /// <summary>
        /// Serves as a hash function for this matrix. Is suitable for use in hashing algorithms
        /// and data structures like a hash table.</summary>
        /// <returns>A hash code for this matrix</returns>
        public override int GetHashCode()
        {
            long bits = 1;

            bits = 31 * bits + M11.GetHashCode();
            bits = 31 * bits + M12.GetHashCode();
            bits = 31 * bits + M13.GetHashCode();
            bits = 31 * bits + M14.GetHashCode();
            bits = 31 * bits + M21.GetHashCode();
            bits = 31 * bits + M22.GetHashCode();
            bits = 31 * bits + M23.GetHashCode();
            bits = 31 * bits + M24.GetHashCode();
            bits = 31 * bits + M31.GetHashCode();
            bits = 31 * bits + M32.GetHashCode();
            bits = 31 * bits + M33.GetHashCode();
            bits = 31 * bits + M34.GetHashCode();
            bits = 31 * bits + M41.GetHashCode();
            bits = 31 * bits + M42.GetHashCode();
            bits = 31 * bits + M43.GetHashCode();
            bits = 31 * bits + M44.GetHashCode();
            return((int)(bits ^ (bits >> 32)));
        }
Example #3
0
        /// <summary>
        /// Returns the string representation of this object</summary>
        /// <param name="format">Optional standard numeric format string for a floating point number.
        /// If null, "R" is used for round-trip support in case the string is persisted.
        /// http://msdn.microsoft.com/en-us/library/vstudio/dwhawy9k(v=vs.100).aspx </param>
        /// <param name="formatProvider">Optional culture-specific formatting provider. This is usually
        /// a CultureInfo object or NumberFormatInfo object. If null, the current culture is used.
        /// Use CultureInfo.InvariantCulture for persistence.</param>
        /// <returns>String representation of object</returns>
        public string ToString(string format, IFormatProvider formatProvider)
        {
            string listSeparator = StringUtil.GetNumberListSeparator(formatProvider);

            // For historic reasons, use "R" for round-trip support, in case this string is persisted.
            if (format == null)
            {
                format = "R";
            }

            return(String.Format(
                       "{0}{9} {1}{9} {2}{9} {3}{9} {4}{9} {5}{9} {6}{9} {7}{9} {8}",
                       M11.ToString(format, formatProvider),
                       M12.ToString(format, formatProvider),
                       M13.ToString(format, formatProvider),
                       M21.ToString(format, formatProvider),
                       M22.ToString(format, formatProvider),
                       M23.ToString(format, formatProvider),
                       M31.ToString(format, formatProvider),
                       M32.ToString(format, formatProvider),
                       M33.ToString(format, formatProvider),
                       listSeparator));
        }
Example #4
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>
 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
 /// </returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = M11.GetHashCode();
         hashCode = (hashCode * 397) ^ M12.GetHashCode();
         hashCode = (hashCode * 397) ^ M13.GetHashCode();
         hashCode = (hashCode * 397) ^ M14.GetHashCode();
         hashCode = (hashCode * 397) ^ M21.GetHashCode();
         hashCode = (hashCode * 397) ^ M22.GetHashCode();
         hashCode = (hashCode * 397) ^ M23.GetHashCode();
         hashCode = (hashCode * 397) ^ M24.GetHashCode();
         hashCode = (hashCode * 397) ^ M31.GetHashCode();
         hashCode = (hashCode * 397) ^ M32.GetHashCode();
         hashCode = (hashCode * 397) ^ M33.GetHashCode();
         hashCode = (hashCode * 397) ^ M34.GetHashCode();
         hashCode = (hashCode * 397) ^ M41.GetHashCode();
         hashCode = (hashCode * 397) ^ M42.GetHashCode();
         hashCode = (hashCode * 397) ^ M43.GetHashCode();
         hashCode = (hashCode * 397) ^ M44.GetHashCode();
         return(hashCode);
     }
 }
Example #5
0
        public string ToString(string formatDouble, IFormatProvider provider)
        {
            StringBuilder s = new StringBuilder();

            s.Append(M11.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M12.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M13.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M21.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M22.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M23.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M31.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M32.ToString(formatDouble, provider));
            s.Append(", ");
            s.Append(M33.ToString(formatDouble, provider));

            return(s.ToString());
        }
Example #6
0
 /// <inheritdoc/>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         var hash = 17;
         hash = hash * 23 + M11.GetHashCode();
         hash = hash * 23 + M12.GetHashCode();
         hash = hash * 23 + M13.GetHashCode();
         hash = hash * 23 + M14.GetHashCode();
         hash = hash * 23 + M21.GetHashCode();
         hash = hash * 23 + M22.GetHashCode();
         hash = hash * 23 + M23.GetHashCode();
         hash = hash * 23 + M24.GetHashCode();
         hash = hash * 23 + M31.GetHashCode();
         hash = hash * 23 + M32.GetHashCode();
         hash = hash * 23 + M33.GetHashCode();
         hash = hash * 23 + M34.GetHashCode();
         hash = hash * 23 + M41.GetHashCode();
         hash = hash * 23 + M42.GetHashCode();
         hash = hash * 23 + M43.GetHashCode();
         hash = hash * 23 + M44.GetHashCode();
         return(hash);
     }
 }
        //// ===========================================================================================================
        //// Equality Members
        //// ===========================================================================================================

        public bool Equals(Matrix4x4 other)
        {
            // Check the diagonals first to see if we can exit early for identity matrix equality.
            return(M00.IsApproximatelyEqual(other.M00) &&
                   M11.IsApproximatelyEqual(other.M11) &&
                   M22.IsApproximatelyEqual(other.M22) &&
                   M33.IsApproximatelyEqual(other.M33) &&

                   M01.IsApproximatelyEqual(other.M01) &&
                   M02.IsApproximatelyEqual(other.M02) &&
                   M03.IsApproximatelyEqual(other.M03) &&

                   M10.IsApproximatelyEqual(other.M10) &&
                   M12.IsApproximatelyEqual(other.M12) &&
                   M13.IsApproximatelyEqual(other.M13) &&

                   M20.IsApproximatelyEqual(other.M20) &&
                   M21.IsApproximatelyEqual(other.M21) &&
                   M23.IsApproximatelyEqual(other.M23) &&

                   M30.IsApproximatelyEqual(other.M30) &&
                   M31.IsApproximatelyEqual(other.M31) &&
                   M32.IsApproximatelyEqual(other.M32));
        }
Example #8
0
 public override int GetHashCode() => M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode() ^ M14.GetHashCode() ^
 M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode() ^ M24.GetHashCode() ^
 M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode() ^ M34.GetHashCode() ^
 M41.GetHashCode() ^ M42.GetHashCode() ^ M43.GetHashCode() ^ M44.GetHashCode();
Example #9
0
        //#endif

        #endregion

        #region IEquatable<Matrix4x4d> Members

        public bool Equals(Matrix4x4d other)
        {
            // Check reference first.
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            // Check for value equality.
            if (!M00.Equals(other.M00))
            {
                return(false);
            }
            if (!M10.Equals(other.M10))
            {
                return(false);
            }
            if (!M20.Equals(other.M20))
            {
                return(false);
            }
            if (!M30.Equals(other.M30))
            {
                return(false);
            }
            if (!M01.Equals(other.M01))
            {
                return(false);
            }
            if (!M11.Equals(other.M11))
            {
                return(false);
            }
            if (!M21.Equals(other.M21))
            {
                return(false);
            }
            if (!M31.Equals(other.M31))
            {
                return(false);
            }
            if (!M02.Equals(other.M02))
            {
                return(false);
            }
            if (!M12.Equals(other.M12))
            {
                return(false);
            }
            if (!M22.Equals(other.M22))
            {
                return(false);
            }
            if (!M32.Equals(other.M32))
            {
                return(false);
            }
            if (!M03.Equals(other.M03))
            {
                return(false);
            }
            if (!M13.Equals(other.M13))
            {
                return(false);
            }
            if (!M23.Equals(other.M23))
            {
                return(false);
            }
            if (!M33.Equals(other.M33))
            {
                return(false);
            }
            return(true);
        }
Example #10
0
 public bool Equals(Float3x3 other)
 => M11.Equals(other.M11) && M12.Equals(other.M12) && M13.Equals(other.M13) &&
 M21.Equals(other.M21) && M22.Equals(other.M22) && M23.Equals(other.M23) &&
 M31.Equals(other.M31) && M32.Equals(other.M32) && M33.Equals(other.M33);
Example #11
0
 public override int GetHashCode()
 {
     return(M11.GetHashCode() ^ M12.GetHashCode() ^
            M21.GetHashCode() ^ M22.GetHashCode() ^
            OffsetX.GetHashCode() ^ OffsetY.GetHashCode());
 }
Example #12
0
 public override int GetHashCode()
 {
     return(M11.GetHashCode() ^ M21.GetHashCode() ^ M31.GetHashCode()
            ^ M12.GetHashCode() ^ M22.GetHashCode() ^ M32.GetHashCode()
            ^ M13.GetHashCode() ^ M23.GetHashCode() ^ M33.GetHashCode());
 }
Example #13
0
 public void Do <T, U, V, W, X>(M12 <T, U, V, W, X> m)
 {
     DoAny(m);
 }
Example #14
0
 /// <summary>
 /// Returns a hash code for this GRaff.Matrix.
 /// </summary>
 /// <returns>An integer value that specifies a hash value for this GRaff.Matrix.</returns>
 public override int GetHashCode()
 => GMath.HashCombine(M00.GetHashCode(), M01.GetHashCode(), M02.GetHashCode(), M10.GetHashCode(), M11.GetHashCode(), M12.GetHashCode());
Example #15
0
 /// <summary>
 /// Returns the hash code for this instance.
 /// </summary>
 /// <returns>The hash code.</returns>
 public override int GetHashCode()
 {
     return(unchecked (M11.GetHashCode() + M12.GetHashCode() +
                       M21.GetHashCode() + M22.GetHashCode() +
                       M31.GetHashCode() + M32.GetHashCode()));
 }
Example #16
0
        /*
         * public static Vector3D operator *(Vector3D vec, Matrix4x4 mat)
         * {
         *  double a = vec.X * mat.M11 + vec.Y * mat.M21 + vec.Z * mat.M31 + mat.M41;
         *  double b = vec.X * mat.M12 + vec.Y * mat.M22 + vec.Z * mat.M32 + mat.M42;
         *  double c = vec.X * mat.M13 + vec.Y * mat.M23 + vec.Z * mat.M33 + mat.M43;
         *  double w = vec.X * mat.M14 + vec.Y * mat.M24 + vec.Z * mat.M34 + mat.M44;
         *
         *  return new Vector3D(a / w, b / w, c / w);
         * }
         */

        public bool Equals(Matrix4x4 other)
        {
            return(M11.Equals(other.M11) && M12.Equals(other.M12) && M13.Equals(other.M13) && M14.Equals(other.M14) && M21.Equals(other.M21) && M22.Equals(other.M22) && M23.Equals(other.M23) && M24.Equals(other.M24) && M31.Equals(other.M31) && M32.Equals(other.M32) && M33.Equals(other.M33) && M34.Equals(other.M34) && M41.Equals(other.M41) && M42.Equals(other.M42) && M43.Equals(other.M43) && M44.Equals(other.M44));
        }
Example #17
0
 public override int GetHashCode()
 => M11.GetHashCode() ^ M12.GetHashCode() ^ M13.GetHashCode()
 ^ M21.GetHashCode() ^ M22.GetHashCode() ^ M23.GetHashCode()
 ^ M31.GetHashCode() ^ M32.GetHashCode() ^ M33.GetHashCode();
Example #18
0
 public bool Equals(Matrix3x2 other)
 {
     return(M11.Equals(other.M11) && M12.Equals(other.M12) && M21.Equals(other.M21) && M22.Equals(other.M22) && M31.Equals(other.M31) && M32.Equals(other.M32));
 }
Example #19
0
 /// <summary>Returns a string representation of this <see cref="IntMatrix2D"/>.</summary>
 /// <param name="format">A standard or custom numeric format string.</param>
 /// <param name="formatProvider">An object that supplies culture-specific formatting information.</param>
 public string ToString(string format, IFormatProvider formatProvider)
 => string.Format(CultureInfo.CurrentCulture, "(({0},{1}), ({2},{3}), ({4},{5}), {6})",
                  M11.ToString(format, formatProvider), M12.ToString(format, formatProvider),
                  M21.ToString(format, formatProvider), M22.ToString(format, formatProvider),
                  M31.ToString(format, formatProvider), M32.ToString(format, formatProvider), M33.ToString(format, formatProvider));
Example #20
0
 public bool Equals(Matrix3X3 other)
 {
     return(M11.Equals(other.M11) && M21.Equals(other.M21) && M31.Equals(other.M31) &&
            M12.Equals(other.M12) && M22.Equals(other.M22) && M32.Equals(other.M32) &&
            M13.Equals(other.M13) && M23.Equals(other.M23) && M33.Equals(other.M33));
 }