예제 #1
0
        /// <summary>
        /// Determines whether the specified matrix is a valid pose matrix.
        /// </summary>
        /// <param name="matrix">The matrix.</param>
        /// <returns>
        /// <see langword="true"/> if the specified matrix is a valid pose matrix; otherwise,
        /// <see langword="false"/>.
        /// </returns>
        /// <remarks>
        /// This method makes a simple, low-performance test.
        /// </remarks>
        public static bool IsValid(Matrix44D matrix)
        {
            Vector4D v1 = matrix * Vector4D.UnitX;
            Vector4D v2 = matrix * Vector4D.UnitY;
            Vector4D v3 = matrix * Vector4D.UnitZ;

            return(Numeric.AreEqual(v1.LengthSquared(), 1) &&
                   Numeric.AreEqual(v2.LengthSquared(), 1) &&
                   Numeric.AreEqual(v3.LengthSquared(), 1) &&
                   Numeric.IsZero(Vector4D.Dot(v1, v2)) &&
                   Numeric.IsZero(Vector4D.Dot(v2, v3)) &&
                   Numeric.IsZero(Vector4D.Dot(v1, v3)) &&
                   Numeric.AreEqual(1.0, matrix.Determinant()) &&
                   Numeric.IsZero(matrix.M30) &&
                   Numeric.IsZero(matrix.M31) &&
                   Numeric.IsZero(matrix.M32) &&
                   Numeric.AreEqual(matrix.M33, 1));
        }