Example #1
0
 /// <summary>
 /// Returns the HashCode for this Matrix3D
 /// </summary>
 /// <returns>
 /// int - the HashCode for this Matrix3D
 /// </returns>
 public override int GetHashCode()
 {
     if (IsDistinguishedIdentity)
     {
         return(c_identityHashCode);
     }
     else
     {
         // 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
        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 #3
0
 /// <summary>
 /// Compares whether current instance is equal to specified <see cref="Matrix" /> without any tolerance.
 /// </summary>
 /// <param name="other">The <see cref="Matrix" /> to compare.</param>
 /// <returns><c>true</c> if the instances are equal; <c>false</c> otherwise.</returns>
 public bool Equals(Matrix other)
 {
     return(M11.Equals(other.M11) && M22.Equals(other.M22) && M33.Equals(other.M33) && M44.Equals(other.M44) &&
            M12.Equals(other.M12) && M13.Equals(other.M13) && M14.Equals(other.M14) && M21.Equals(other.M21) &&
            M23.Equals(other.M23) && M24.Equals(other.M24) && M31.Equals(other.M31) && M32.Equals(other.M32) &&
            M34.Equals(other.M34) && M41.Equals(other.M41) && M42.Equals(other.M42) && M43.Equals(other.M43));
 }
Example #4
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 that represents matrix</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}{16} {1}{16} {2}{16} {3}{16} {4}{16} {5}{16} {6}{16} {7}{16} {8}{16} {9}{16} " +
                       "{10}{16} {11}{16} {12}{16} {13}{16} {14}{16} {15}",
                       M11.ToString(format, formatProvider),
                       M12.ToString(format, formatProvider),
                       M13.ToString(format, formatProvider),
                       M14.ToString(format, formatProvider),
                       M21.ToString(format, formatProvider),
                       M22.ToString(format, formatProvider),
                       M23.ToString(format, formatProvider),
                       M24.ToString(format, formatProvider),
                       M31.ToString(format, formatProvider),
                       M32.ToString(format, formatProvider),
                       M33.ToString(format, formatProvider),
                       M34.ToString(format, formatProvider),
                       M41.ToString(format, formatProvider),
                       M42.ToString(format, formatProvider),
                       M43.ToString(format, formatProvider),
                       M44.ToString(format, formatProvider),
                       listSeparator));
        }
Example #5
0
 public override int GetHashCode()
 {
     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() ^
          M41.GetHashCode() ^ M42.GetHashCode() ^ M43.GetHashCode() ^ M44.GetHashCode());
 }
Example #6
0
 /// <summary>
 /// Gets the hash code for a given Matrix4.
 /// </summary>
 /// <returns>The calculated hash code.</returns>
 public override int GetHashCode()
 {
     // Note this method of hash code generation is similar to what the XNA framework does
     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()
            + M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + M44.GetHashCode());
 }
Example #7
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 #8
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 #9
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);
     }
 }
Example #10
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 #11
0
 /// <inheritdoc />
 public bool Equals(Matrix4x4 other) =>
 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 #12
0
 public void dump(string name = "")
 {
     DOut.pl(nameof(UMatrix4) + " " + name + " {");
     DOut.Indent++;
     DOut.pl(M11.ToString() + ", " + M12.ToString() + ", " + M13.ToString() + ", " + M14.ToString());
     DOut.pl(M21.ToString() + ", " + M22.ToString() + ", " + M23.ToString() + ", " + M24.ToString());
     DOut.pl(M31.ToString() + ", " + M32.ToString() + ", " + M33.ToString() + ", " + M34.ToString());
     DOut.pl(M41.ToString() + ", " + M42.ToString() + ", " + M43.ToString() + ", " + M44.ToString());
     DOut.Indent--;
     DOut.pl("}");
 }