Inverse() public method

get inverse matrix
public Inverse ( ) : Matrix4
return Matrix4
Beispiel #1
0
        /// <summary>
        /// calculate the matrix used to transform 3D to 2D
        /// </summary>
        /// <returns>maxtrix is use to transform 3d points to 2d</returns>
        public virtual Matrix4 Compute3DTo2DMatrix()
        {
            Matrix4 result = Matrix4.Multiply(
                m_to2DMatrix.Inverse(), m_moveToCenterMatrix.Inverse());

            m_transformMatrix = Matrix4.Multiply(result, m_scaleMatrix);
            return(m_transformMatrix);
        }
Beispiel #2
0
        /// <summary>
        /// Get the bound of a face
        /// </summary>
        /// <returns>points array stores the bound of the face</returns>
        public override PointF[] GetFaceBounds()
        {
            Matrix4 matrix = m_to2DMatrix;
            Matrix4 inverseMatrix = matrix.Inverse();
            float   minX = 0, maxX = 0, minY = 0, maxY = 0;
            bool    bFirstPoint = true;

            //get the max and min point on the face
            for (int i = 0; i < m_points.Count; i++)
            {
                List <XYZ> points = m_points[i];
                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 face
            PointF[] resultPoints = new PointF[2] {
                new PointF(minX, minY), new PointF(maxX, maxY)
            };
            return(resultPoints);
        }
Beispiel #3
0
        /// <summary>
        /// transform the point on Form to 3d world coordinate of revit
        /// </summary>
        /// <param name="ps">contain the points to be transformed</param>
        /// <returns>Vector list contains points being transformed</returns>
        public virtual List <Vector4> Transform2DTo3D(Point[] ps)
        {
            List <Vector4> result = new List <Vector4>();

            TransformPoints(ps);
            Matrix4 transformMatrix = Matrix4.Multiply(
                m_scaleMatrix.Inverse(), m_moveToCenterMatrix);

            transformMatrix = Matrix4.Multiply(transformMatrix, m_to2DMatrix);
            foreach (Point point in ps)
            {
                Vector4 v = new Vector4(point.X, point.Y, 0);
                v = transformMatrix.Transform(v);
                result.Add(v);
            }
            return(result);
        }