Inverse() public method

get inverse matrix
public Inverse ( ) : Matrix4
return Matrix4
Esempio n. 1
0
        /// <summary>
        /// calculate the matrix used to transform 2D to 3D
        /// </summary>
        /// <returns>maxtrix is use to transform 2d points to 3d</returns>
        public Matrix4 Get2DTo3DMatrix()
        {
            Matrix4 matrix = Matrix4.Multiply(
                m_MoveToPictureBoxCenter.Inverse(), m_scaleMatrix.Inverse());

            matrix = Matrix4.Multiply(
                matrix, m_moveToCenterMatrix);
            return(Matrix4.Multiply(matrix, m_to2DMatrix));
        }
Esempio n. 2
0
        /// <summary>
        /// calculate the matrix used to transform 3D to 2D
        /// </summary>
        /// <returns>maxtrix is use to transform 3d points to 2d</returns>
        public Matrix4 Get3DTo2DMatrix()
        {
            Matrix4 result = Matrix4.Multiply(
                m_to2DMatrix.Inverse(), m_moveToCenterMatrix.Inverse());

            result = Matrix4.Multiply(result, m_scaleMatrix);
            return(Matrix4.Multiply(result, m_MoveToPictureBoxCenter));
        }
Esempio n. 3
0
        /// <summary>
        /// Get max and min coordinates of all points
        /// </summary>
        /// <returns>points array stores the bound of all points</returns>
        public PointF[] GetBoundsPoints()
        {
            Matrix4 matrix = m_to2DMatrix;
            Matrix4 inverseMatrix = matrix.Inverse();
            double  minX = 0, maxX = 0, minY = 0, maxY = 0;
            bool    bFirstPoint = true;

            //get all points on slab
            List <XYZ> points = new List <XYZ>();

            foreach (Edge edge in m_edges)
            {
                List <XYZ> edgexyzs = edge.Tessellate() as List <XYZ>;
                foreach (Autodesk.Revit.DB.XYZ xyz in edgexyzs)
                {
                    points.Add(xyz);
                }
            }

            //get the max and min point on the face
            foreach (Autodesk.Revit.DB.XYZ point in points)
            {
                Vector4 v  = new Vector4(point);
                Vector4 v1 = inverseMatrix.Transform(v);

                if (bFirstPoint)
                {
                    minX        = maxX = v1.X;
                    minY        = maxY = v1.Y;
                    bFirstPoint = false;
                }
                else
                {
                    if (v1.X < minX)
                    {
                        minX = v1.X;
                    }
                    else if (v1.X > maxX)
                    {
                        maxX = v1.X;
                    }

                    if (v1.Y < minY)
                    {
                        minY = v1.Y;
                    }
                    else if (v1.Y > maxY)
                    {
                        maxY = v1.Y;
                    }
                }
            }
            //return an array with max and min value of all points
            PointF[] resultPoints = new PointF[2] {
                new PointF((float)minX, (float)minY), new PointF((float)maxX, (float)maxY)
            };
            return(resultPoints);
        }