问题提出:在空间坐标系中,插入一图块需要的基本条件是,插入的空间坐标点,X,Y,Z轴的方向角。 我的解决方法是用一个线段来确定插入空间坐标系中的方向角,特点是程序调试时对方向角的确认比较直观,提高工作效率。 在空间任意两点可以确定一条直线,两点坐标确定,一种方法是输入坐标,另一种是通过交互式方法确定两点坐标。 Function RotateZ_Axis(ByVal sPoint As Variant, ByVal ePoint As Variant) As Double Dim EntAngle As Double Dim deltaX As Double, deltaY As Double, deltaZ As Double deltaX = sPoint(0) - ePoint(0): deltaY = sPoint(1) - ePoint(1): deltaZ = sPoint(2) - ePoint(2): If deltaY >= 0 And deltaX > 0 Then EntAngle = Atn(deltaY / deltaX) ElseIf deltaY >= 0 And deltaX < 0 Then EntAngle = Pi + Atn(deltaY / deltaX) ElseIf deltaY < 0 And deltaX < 0 Then EntAngle = Pi + Atn(deltaY / deltaX) ElseIf deltaY < 0 And deltaX > 0 Then EntAngle = 2 * Pi + Atn(deltaY / deltaX) End If If deltaX = 0 Then If deltaY > 0 Then EntAngle = Pi / 2 ElseIf deltaY > 0 Then EntAngle = Pi * 1.5 End If End If RotateZ_Axis = EntAngle End Function Function RotateX_Axis(txtEnt As String) As Double Dim Ent As AcadLine Dim EntAngle As Double Set Ent = ThisDrawing.HandleToObject(txtEnt) If deltaY >= 0 And deltaX > 0 Then EntAngle = Atn(deltaY / deltaX) ElseIf deltaY >= 0 And deltaX < 0 Then EntAngle = Pi + Atn(deltaY / deltaX) ElseIf deltaY < 0 And deltaX < 0 Then EntAngle = Pi + Atn(deltaY / deltaX) ElseIf deltaY < 0 And deltaX > 0 Then EntAngle = 2 * Pi + Atn(deltaY / deltaX) End If If deltaX = 0 Then If deltaY > 0 Then EntAngle = Pi / 2 ElseIf deltaY > 0 Then EntAngle = Pi * 1.5 End If End If RotateZ_Axis = EntAngle End Function
RotateZ_Axis,RotateX_Axis,RotateY_Axis返回的的是直线在X,Y,Z坐标轴的方向角。 请问各位大侠是否还有更好的几何解决方法。 |