enocheasty 发表于 2007-10-23 23:08:00

又有问题了!UCS与WCS的夹角

<p>因为我想让我的文字在UCS下也能够对齐到我需要的直线,我只能在WCS做到这一点,但是如果能够知道目前UCS和WCS的X轴的夹角,那么也可以做到,可是都不知道怎么求这个角度,之前用了当前UCS的Origin,XVector,YVector属性,可是用这三个点画出来的三角形好怪异,这个三角形的三个边没有一个是与UCS的坐标轴垂直或者平行的,那它这个x向量,y向量到底是指的什么呢??</p><p>或者,有什么更好,更便捷的方法,让UCS中文字和一条直线对齐呢?</p><p>请大家指教!!!!</p>

alin 发表于 2007-10-24 15:04:00

<p>很明显你对XVector和YVector的概念理解错了,如果你用XVector,YVector和(0,0,0)画三角形就对了。要求UCS与WCS的夹角应用AngleFromXAxis方法,参数取(0,0,0)和XVector两点</p>

enocheasty 发表于 2007-10-24 19:37:00

<p>感谢版主老大!</p><p>以后可能还有好多问题,就要麻烦你了!!</p>

兰州人 发表于 2007-10-25 13:00:00

<p>Function rotateXYangle(ByVal sPoint As Variant, ePoint As Variant, txtEnt As String) As Double<br/>&nbsp; Dim ll As AcadEntity, Alfa As Double, lll As AcadLine, Rot3D As AcadEntity<br/>&nbsp; Dim pp(0 To 2) As Double, ppp(0 To 2) As Double<br/>&nbsp; ''<br/>&nbsp; pp(0) = 0: pp(1) = 0: pp(2) = 0<br/>&nbsp; Set Rot3D = ThisDrawing.ObjectIdToObject(txtEnt)<br/>&nbsp; ''<br/>&nbsp; Dim x As Double, x1 As Double, y As Double, y1 As Double, z As Double, z1 As Double<br/>&nbsp; Dim deltaX As Double, deltaY As Double, deltaZ As Double<br/>''<br/>&nbsp; x1 = sPoint(0): x = ePoint(0)<br/>&nbsp; y1 = sPoint(1): y = ePoint(1)<br/>&nbsp; z1 = sPoint(2): z = ePoint(2)</p><p>''<br/>&nbsp; deltaX = x - x1: deltaY = y - y1: deltaZ = z - z1<br/>&nbsp; Debug.Print deltaX, deltaY<br/>&nbsp;&nbsp;&nbsp;&nbsp; If deltaX &gt; 0 And deltaY &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = Atn(deltaY / deltaX)<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaX &lt; 0 And deltaY &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debug.Print Atn(deltaY / deltaX)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = Pi + Atn(deltaY / deltaX)<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaY &lt; 0 And deltaX &lt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = Pi + Atn(deltaY / deltaX)<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaX &gt; 0 And deltaY &lt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = 2 * Pi + Atn(deltaY / deltaX)<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaY = 0 And deltaX &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = 0<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaY = 0 And deltaX &lt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = Pi<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaY &lt; 0 And deltaX = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = 3 / 2 * Pi<br/>&nbsp;&nbsp;&nbsp;&nbsp; ElseIf deltaY &gt; 0 And deltaX = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rotateXYangle = Pi / 2<br/>&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp; <br/>''''<br/>&nbsp; Alfa = rotateXYangle + Alfa + Pi / 2<br/>''<br/>&nbsp; ppp(0) = sPoint(0) + 4 * Cos(Alfa): ppp(1) = sPoint(1) + 4 * Sin(Alfa): ppp(2) = sPoint(2)<br/>&nbsp; Set lll = ThisDrawing.ModelSpace.AddLine(sPoint, ppp)</p><p>''<br/>&nbsp; Rot3D.Move pp, sPoint<br/>&nbsp; <br/>&nbsp; <br/>&nbsp; Rot3D.Rotate3D ppp, sPoint, -Pi / 2<br/>&nbsp; Rot3D.Rotate3D sPoint, ePoint, -Pi / 2<br/>''<br/>End Function</p>
页: [1]
查看完整版本: 又有问题了!UCS与WCS的夹角