- UID
- 1
- 积分
- 15891
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-9-16 14:05:42
|
显示全部楼层
下面这个是关于AcGeVector3d::angleTo() 的参考向量的理解。
- [FONT=courier new]
- AcGeVector3d::angleTo() explained
- ID 45178
- Applies to: AutoCAD 2000
-
- Date 6/21/2000
-
- This document is part of ObjectARX ObjectARX Technical Newsletter - December 1999
- Question
- The method AcGeVector3d::angleTo(const AcGeVector3d &vec, const AcGeVector3d&
- refVec) const is described as follows in the ARXREF.HLP:
- "Returns the angle between this vector and the vector 'vec' in the range [0, 2 *
- PI]; If ( refVec.dotProduct(crossProduct(vec)) >= 0.0 ) the return value
- coincides with the return value of the function angleTo( vec ). Otherwise the
- return value is 2*PI minus the return value of the function angleTo( vec )."
- What exactly is meant when passing as refVec?
- Answer
- According to the online documentation, there are two overloaded functions for
- angleTo().
- One is:
- double AcGeVector3d::angleTo( const AcGeVector3d& vec) const;
- Returns the angle between this vector and the vector vec in the range [0, Pi].
- Another is:
- double AcGeVector3d::angleTo(const AcGeVector3d& vec, const AcGeVector3d&
- refVec) const;
- Returns the angle between this vector and the vector vec in the range [0, 2 x
- Pi].
- If (refVec.dotProduct(crossProduct(vec)) >= 0.0), then the return value
- coincides with the return value of the function angleTo(vec). Otherwise, the
- return value is 2 x Pi minus the return value of the function angleTo(vec).
- Therefore, the return angle's range is different. That's exactly why the refVec
- is needed. Dot Product, as you know, is a method to find out how parallel two
- lines are. The result of the calculation is a scalar. This is most useful if you
- use unit vectors (get a number between -1 and 1), such as our usage here
- (vectors).
- |x1| |x2|
- |y1| . |y2| = (x1 * x2) + (y1 * y2) + (z1 * z2)
- |z1| |z2|
- Cross Product is the process of multiplying two vectors together to get a
- normal to the plane they describe with the Vector (0,0,0).
- |x1| |x2| |y1*z2 - z1*y2|
- |y1| x |y2| = |z1*x2 - x1*z2|
- |z1| |z2| |x1*y2 - y1*x2|
- Therefore, in the code,
- refVec.dotProduct(crossProduct(vec))
- it first checks the angle between the normal (for the plane which 'this' vector
- and 'vec' vector is on) and the refVec. As it states, if
- (refVec.dotProduct(crossProduct(vec)) >= 0.0), then the return value coincides
- with the return value of the function angleTo(vec). Otherwise the return value
- is 2 x Pi minus the return value of the function angleTo(vec).
- You can actually use the normal vector for the plane that 'this' vector is on,
- as the refVec, to check the 'vec'. Of course, you can choose other vectors that
- are not the same as the normal vector depends on your application needs.
- [/FONT]
复制代码 |
|