UCS和WCS之间的坐标互换

时间:2021-06-26 15:26:58
 
    ''' <summary>从UCS转换到WCS。</summary>
    ''' <param name="t">要转换的点.</param>
    Public Shared Function UcsToWcs(ByVal Pt As Point3d) As Point3d
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim mt As Matrix3d = ed.CurrentUserCoordinateSystem
        Dim newPoint As Point3d = Pt.TransformBy(mt)
        Return newPoint

    End Function


    ''' <summary>从WCS转换到UCS。</summary>
    ''' <param name="t">要转换的点.</param>
    Public Shared Function WcsToUcs(ByVal Pt As Point3d) As Point3d
        Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
        Dim vect As Vector3d = db.Ucsorg.GetVectorTo(New Point3d(0, 0, 0))
        Dim mt As Matrix3d = Matrix3d.Displacement(vect)
        Dim newPoint As Point3d = Pt.TransformBy(mt)
        Return newPoint
    End Function