明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1679|回复: 3

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

[复制链接]
发表于 2007-10-23 23:08:00 | 显示全部楼层 |阅读模式

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

或者,有什么更好,更便捷的方法,让UCS中文字和一条直线对齐呢?

请大家指教!!!!

发表于 2007-10-24 15:04:00 | 显示全部楼层

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

 楼主| 发表于 2007-10-24 19:37:00 | 显示全部楼层

感谢版主老大!

以后可能还有好多问题,就要麻烦你了!!

发表于 2007-10-25 13:00:00 | 显示全部楼层

Function rotateXYangle(ByVal sPoint As Variant, ePoint As Variant, txtEnt As String) As Double
  Dim ll As AcadEntity, Alfa As Double, lll As AcadLine, Rot3D As AcadEntity
  Dim pp(0 To 2) As Double, ppp(0 To 2) As Double
  ''
  pp(0) = 0: pp(1) = 0: pp(2) = 0
  Set Rot3D = ThisDrawing.ObjectIdToObject(txtEnt)
  ''
  Dim x As Double, x1 As Double, y As Double, y1 As Double, z As Double, z1 As Double
  Dim deltaX As Double, deltaY As Double, deltaZ As Double
''
  x1 = sPoint(0): x = ePoint(0)
  y1 = sPoint(1): y = ePoint(1)
  z1 = sPoint(2): z = ePoint(2)

''
  deltaX = x - x1: deltaY = y - y1: deltaZ = z - z1
  Debug.Print deltaX, deltaY
     If deltaX > 0 And deltaY > 0 Then
       rotateXYangle = Atn(deltaY / deltaX)
     ElseIf deltaX < 0 And deltaY > 0 Then
       Debug.Print Atn(deltaY / deltaX)
       rotateXYangle = Pi + Atn(deltaY / deltaX)
     ElseIf deltaY < 0 And deltaX < 0 Then
       rotateXYangle = Pi + Atn(deltaY / deltaX)
     ElseIf deltaX > 0 And deltaY < 0 Then
       rotateXYangle = 2 * Pi + Atn(deltaY / deltaX)
     ElseIf deltaY = 0 And deltaX > 0 Then
       rotateXYangle = 0
     ElseIf deltaY = 0 And deltaX < 0 Then
       rotateXYangle = Pi
     ElseIf deltaY < 0 And deltaX = 0 Then
       rotateXYangle = 3 / 2 * Pi
     ElseIf deltaY > 0 And deltaX = 0 Then
       rotateXYangle = Pi / 2
     End If
    
''''
  Alfa = rotateXYangle + Alfa + Pi / 2
''
  ppp(0) = sPoint(0) + 4 * Cos(Alfa): ppp(1) = sPoint(1) + 4 * Sin(Alfa): ppp(2) = sPoint(2)
  Set lll = ThisDrawing.ModelSpace.AddLine(sPoint, ppp)

''
  Rot3D.Move pp, sPoint
 
 
  Rot3D.Rotate3D ppp, sPoint, -Pi / 2
  Rot3D.Rotate3D sPoint, ePoint, -Pi / 2
''
End Function

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 12:32 , Processed in 0.151931 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表