public static bool DecomposeIntoRotationAndScale(Matrix3D source, out Matrix3D rotation, out Vector3D scale)
        {
            source.OffsetX = 0.0;
            source.OffsetY = 0.0;
            source.OffsetZ = 0.0;
            Matrix3D U;
            Vector3D S;
            Matrix3D VTranspose;
            bool     flag      = Matrix3DOperations.SVD(source, out U, out S, out VTranspose);
            Matrix3D matrix3D1 = Matrix3DOperations.Transpose(VTranspose);
            Matrix3D matrix3D2 = new Matrix3D()
            {
                M11 = S.X,
                M22 = S.Y,
                M33 = S.Z,
                M44 = 1.0
            };

            rotation = U * matrix3D1;
            Matrix3D matrix3D3 = rotation;

            matrix3D3.Invert();
            Matrix3D matrix    = source * matrix3D3;
            Matrix3D matrix3D4 = matrix3D3 * source;
            double   tolerance = 1E-13;

            scale = !Matrix3DOperations.IsDiagonal(matrix, tolerance) ? new Vector3D(matrix3D4.M11, matrix3D4.M22, matrix3D4.M33) : new Vector3D(matrix.M11, matrix.M22, matrix.M33);
            return(flag);
        }
        public static bool DecomposeIntoRotationAndScale(Matrix source, out Matrix rotation, out Vector scale)
        {
            source.OffsetX = 0.0;
            source.OffsetY = 0.0;
            Matrix U;
            Vector S;
            Matrix VTranspose;
            bool   flag    = Matrix3DOperations.SVD(source, out U, out S, out VTranspose);
            Matrix matrix1 = Matrix3DOperations.Transpose(VTranspose);
            Matrix matrix2 = new Matrix()
            {
                M11 = S.X,
                M22 = S.Y
            };

            rotation = U * matrix1;
            Matrix matrix3 = rotation;

            matrix3.Invert();
            Matrix matrix4   = source * matrix3;
            Matrix matrix5   = matrix3 * source;
            double tolerance = 1E-13;

            scale = !Matrix3DOperations.IsDiagonal(matrix4, tolerance) ? new Vector(matrix5.M11, matrix5.M22) : new Vector(matrix4.M11, matrix4.M22);
            return(flag);
        }