Example #1
0
        /// <summary>
        /// Calculates the inverse matrix.
        /// </summary>
        /// <returns>Inverse Matrix3.</returns>
        public Matrix3 Inverse()
        {
            double det = this.Determinant();
            Matrix3 resultado = new Matrix3();
            if (MathHelper.IsZero(det))
            {
                throw (new ArithmeticException("The matrix is not invertible."));
            }
            det = 1/det;

            resultado.M11 = det*(this.mM22*this.mM33 - this.mM23*this.mM32);
            resultado.M12 = det*(this.mM13*this.mM32 - this.mM12*this.mM33);
            resultado.M13 = det*(this.mM12*this.mM23 - this.mM13*this.mM22);

            resultado.M21 = det*(this.mM23*this.mM31 - this.mM21*this.mM33);
            resultado.M22 = det*(this.mM11*this.mM33 - this.mM13*this.mM31);
            resultado.M23 = det*(this.mM13*this.mM21 - this.mM11*this.mM23);

            resultado.M31 = det*(this.mM21*this.mM32 - this.mM22*this.mM31);
            resultado.M32 = det*(this.mM12*this.mM31 - this.mM11*this.mM32);
            resultado.M33 = det*(this.mM11*this.mM22 - this.mM12*this.mM21);

            return resultado;
        }
Example #2
0
        /// <summary>
        /// Transform a 2d point from object coordinates to world coordinates.
        /// </summary>
        /// <param name="point">Points to transform.</param>
        /// <param name="zAxis">Object normal vector.</param>
        /// <param name="elevation">Object elevation.</param>
        /// <returns>Transformed point.</returns>
        public static Vector3 Transform(Vector2 point, Vector3 zAxis, double elevation)
        {
            Matrix3 trans = ArbitraryAxis(zAxis);

            return(trans * new Vector3(point.X, point.Y, elevation));
        }