找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1590|回复: 4

[ARX程序]:如何计算AcGeCircArc3d的refVec?

[复制链接]
发表于 2002-9-16 14:00:24 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
AcGeCircArc3d的refVec是如何计算的?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-16 14:03:50 | 显示全部楼层
关于参考向量的问题,涉及到ACAD的弧对象保存角度的方法,还有一个地方就是AcGeVector3d::angleTo中也会遇到,下面给你贴两篇资料,你理解下


  1. [FONT=courier new]
  2. Angles in AcDbArc and AcGeCircArc2d  
  3. ID    13119  
  4. Applies to:    AutoCAD 2000
  5. AutoCAD 2000I
  6. AutoCAD 2002

  7. Date    1/29/2002  

  8. This document is part of    AcGe (Geometry Library)     


  9. Question
  10. I use the AutoCAD RECTANG command to draw an unrotated rectangle with the
  11. FILLET option. When prompted for the startAng and endAng of the resulting
  12. AcDbPolyline's corner arcs, the values are always 0 and 90 degree. However, if
  13. the polyline is selected and LIST is typed the values for startAng and endAng
  14. are displayed correctly with only the upper-right corner sweeping from 90 to 0
  15. degrees. Why ?
  16. Answer
  17. The LIST command and entity definition data for an arc uses AcDbArc class
  18. information, whereas a polyline provides AcGeCircArc2d information.

  19. Querying the arcs of a filleted rectangle, which is represented as a polyline
  20. entity, pPoly:


  21. int n = pPoly->numVerts();
  22. AcGeCircArc2d arc; AcGeVector2d dir;

  23. for (int i=0; i < n; i++) {
  24.     if (pPoly->segType(i) != AcDbPolyline::kArc)
  25.         continue;
  26.     if ((es = pPoly->getArcSegAt(i, arc)) == Acad::eOk) {
  27.         dir =  arc.refVec();
  28.         acutPrintf("\nVertex %d:\tstartang= %f \t endang= %f \trefvec=
  29. {%i %i}",
  30.             i, arc.startAng(), arc.endAng(), (int)dir[0],
  31. (int)dir[1]);
  32.     }
  33. }

  34. Printed results are:
  35. Vertex 0: startang= 0.000000 endang= 1.570796 refvec= {-1 0}
  36. Vertex 2: startang= 0.000000 endang= 1.570796 refvec= {0 1}
  37. Vertex 4: startang= 0.000000 endang= 1.570796 refvec= {1 0}
  38. Vertex 6: startang= 0.000000 endang= 1.570796 refvec= {0 -1}

  39. This is the expected result because the angles are measured with respect to the
  40. arc's reference vector, which in this case is always oriented to contain the
  41. startpoint of the arc. Therefore, vertex 0 is the upper left arc (corner) of an
  42. unrotated rectangle. Its reference vector of [-1 0] proceeds from the arc's
  43. center point along the -x axis in WCS. The startpoint of the arc then lies on
  44. this reference vector, and thus the start angle from the reference vector is 0.
  45. The arc's endpoint is found 1.57 rads away from the startpoint/reference vector
  46. in a + clockwise direction.

  47. The start and end angles for an AcDbArc are invariably measured in respect to
  48. the +x axis. Also, the positive direction for rotation is considered to be
  49. counter-clockwise. Vertex 0, the upper-left corner will then list a start
  50. angle=180 and an end angle=90.
  51. [/FONT]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-16 14:05:42 | 显示全部楼层
下面这个是关于AcGeVector3d::angleTo() 的参考向量的理解。


  1. [FONT=courier new]

  2. AcGeVector3d::angleTo() explained  
  3. ID    45178  
  4. Applies to:    AutoCAD 2000

  5. Date    6/21/2000  

  6. This document is part of    ObjectARX   ObjectARX Technical Newsletter - December 1999     


  7. Question
  8. The method AcGeVector3d::angleTo(const AcGeVector3d &vec, const AcGeVector3d&
  9. refVec) const is described as follows in the ARXREF.HLP:

  10. "Returns the angle between this vector and the vector 'vec' in the range [0, 2 *
  11. PI]; If ( refVec.dotProduct(crossProduct(vec)) >=  0.0 ) the return value
  12. coincides with the return value of the function angleTo( vec ). Otherwise the
  13. return value is 2*PI  minus the return value of the function angleTo( vec )."

  14. What exactly is meant when passing as refVec?
  15. Answer
  16. According to the online documentation, there are two overloaded functions for
  17. angleTo().

  18. One is:
  19. double AcGeVector3d::angleTo( const AcGeVector3d& vec) const;
  20. Returns the angle between this vector and the vector vec in the range [0, Pi].

  21. Another is:
  22. double AcGeVector3d::angleTo(const AcGeVector3d& vec, const AcGeVector3d&
  23. refVec) const;
  24. Returns the angle between this vector and the vector vec in the range [0, 2 x
  25. Pi].

  26. If (refVec.dotProduct(crossProduct(vec)) >= 0.0), then the return value
  27. coincides with the return value of the function angleTo(vec). Otherwise, the
  28. return value is 2 x Pi minus the return value of the function angleTo(vec).

  29. Therefore, the return angle's range is different. That's exactly why the refVec
  30. is needed. Dot Product, as you know, is a method to find out how parallel two
  31. lines are. The result of the calculation is a scalar. This is most useful if you
  32. use unit vectors (get a number between -1 and 1), such as our usage here
  33. (vectors).
  34. |x1| |x2|

  35. |y1| . |y2| = (x1 * x2) + (y1 * y2) + (z1 * z2)

  36. |z1| |z2|
  37. Cross Product  is the process of multiplying two vectors together to get a
  38. normal to the plane they describe with the Vector (0,0,0).
  39. |x1| |x2| |y1*z2 - z1*y2|

  40. |y1| x |y2| = |z1*x2 - x1*z2|

  41. |z1| |z2| |x1*y2 - y1*x2|
  42. Therefore, in the code,
  43. refVec.dotProduct(crossProduct(vec))
  44. it first checks the angle between the normal (for the plane which 'this' vector
  45. and 'vec' vector is on) and the refVec. As it states, if
  46. (refVec.dotProduct(crossProduct(vec)) >= 0.0), then the return value coincides
  47. with the return value of the function angleTo(vec). Otherwise the return value
  48. is 2 x Pi minus the return value of the function angleTo(vec).

  49. You can actually use the normal vector for the plane that 'this' vector is on,
  50. as the refVec, to check the 'vec'. Of course, you can choose other vectors that
  51. are not the same as the normal vector depends on your application needs.
  52. [/FONT]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-16 14:07:29 | 显示全部楼层
给你贴两个函数,在AcGeCircArc3d和AcDbArc间转换。


  1. [FONT=courier new]

  2. void convertArc2Arc( AcGeCircArc3d*pGeArc, AcDbArc*&pDbArc )

  3. {
  4.        
  5.         AcGePoint3d center = pGeArc->center();
  6.        
  7.         AcGeVector3d normal = pGeArc->normal();
  8.        
  9.         AcGeVector3d refVec = pGeArc->refVec();
  10.        
  11.         AcGePlane plane = AcGePlane(center, normal);
  12.        
  13.         double ang = refVec.angleOnPlane(plane);
  14.        
  15.         pDbArc = new AcDbArc(center, normal, pGeArc->radius(),pGeArc->startAng() + ang, pGeArc->endAng() + ang );
  16.        
  17. }



  18. void convertArc2Arc( AcDbArc*pDbArc, AcGeCircArc3d*&pGeArc)

  19. {
  20.        
  21.         pGeArc = new AcGeCircArc3d(
  22.                
  23.                 pDbArc->center(),
  24.                
  25.                 pDbArc->normal(),
  26.                
  27.                 pDbArc->normal().perpVector(),
  28.                
  29.                 pDbArc->radius(),
  30.                
  31.                 pDbArc->startAngle(),
  32.                
  33.                 pDbArc->endAngle());
  34.        
  35. }

  36. [/FONT]
复制代码
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 145个

财富等级: 日进斗金

发表于 2002-9-16 14:13:22 | 显示全部楼层
由 NORMAL 法向量,得到refVec 参考向量,实际就是X轴。

pDbArc->normal().perpVector()

对于世界座标系,Z=0,0,1,那么X轴=1,0,0
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-15 20:48 , Processed in 0.178107 second(s), 39 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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