又有问题了!UCS与WCS的夹角
<p>因为我想让我的文字在UCS下也能够对齐到我需要的直线,我只能在WCS做到这一点,但是如果能够知道目前UCS和WCS的X轴的夹角,那么也可以做到,可是都不知道怎么求这个角度,之前用了当前UCS的Origin,XVector,YVector属性,可是用这三个点画出来的三角形好怪异,这个三角形的三个边没有一个是与UCS的坐标轴垂直或者平行的,那它这个x向量,y向量到底是指的什么呢??</p><p>或者,有什么更好,更便捷的方法,让UCS中文字和一条直线对齐呢?</p><p>请大家指教!!!!</p> <p>很明显你对XVector和YVector的概念理解错了,如果你用XVector,YVector和(0,0,0)画三角形就对了。要求UCS与WCS的夹角应用AngleFromXAxis方法,参数取(0,0,0)和XVector两点</p> <p>感谢版主老大!</p><p>以后可能还有好多问题,就要麻烦你了!!</p> <p>Function rotateXYangle(ByVal sPoint As Variant, ePoint As Variant, txtEnt As String) As Double<br/> Dim ll As AcadEntity, Alfa As Double, lll As AcadLine, Rot3D As AcadEntity<br/> Dim pp(0 To 2) As Double, ppp(0 To 2) As Double<br/> ''<br/> pp(0) = 0: pp(1) = 0: pp(2) = 0<br/> Set Rot3D = ThisDrawing.ObjectIdToObject(txtEnt)<br/> ''<br/> Dim x As Double, x1 As Double, y As Double, y1 As Double, z As Double, z1 As Double<br/> Dim deltaX As Double, deltaY As Double, deltaZ As Double<br/>''<br/> x1 = sPoint(0): x = ePoint(0)<br/> y1 = sPoint(1): y = ePoint(1)<br/> z1 = sPoint(2): z = ePoint(2)</p><p>''<br/> deltaX = x - x1: deltaY = y - y1: deltaZ = z - z1<br/> Debug.Print deltaX, deltaY<br/> If deltaX > 0 And deltaY > 0 Then<br/> rotateXYangle = Atn(deltaY / deltaX)<br/> ElseIf deltaX < 0 And deltaY > 0 Then<br/> Debug.Print Atn(deltaY / deltaX)<br/> rotateXYangle = Pi + Atn(deltaY / deltaX)<br/> ElseIf deltaY < 0 And deltaX < 0 Then<br/> rotateXYangle = Pi + Atn(deltaY / deltaX)<br/> ElseIf deltaX > 0 And deltaY < 0 Then<br/> rotateXYangle = 2 * Pi + Atn(deltaY / deltaX)<br/> ElseIf deltaY = 0 And deltaX > 0 Then<br/> rotateXYangle = 0<br/> ElseIf deltaY = 0 And deltaX < 0 Then<br/> rotateXYangle = Pi<br/> ElseIf deltaY < 0 And deltaX = 0 Then<br/> rotateXYangle = 3 / 2 * Pi<br/> ElseIf deltaY > 0 And deltaX = 0 Then<br/> rotateXYangle = Pi / 2<br/> End If<br/> <br/>''''<br/> Alfa = rotateXYangle + Alfa + Pi / 2<br/>''<br/> ppp(0) = sPoint(0) + 4 * Cos(Alfa): ppp(1) = sPoint(1) + 4 * Sin(Alfa): ppp(2) = sPoint(2)<br/> Set lll = ThisDrawing.ModelSpace.AddLine(sPoint, ppp)</p><p>''<br/> Rot3D.Move pp, sPoint<br/> <br/> <br/> Rot3D.Rotate3D ppp, sPoint, -Pi / 2<br/> Rot3D.Rotate3D sPoint, ePoint, -Pi / 2<br/>''<br/>End Function</p>
页:
[1]