- UID
- 76071
- 积分
- 1505
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-8-30
- 最后登录
- 1970-1-1
|
发表于 2014-9-2 19:06:01
|
显示全部楼层
点或向量在比较时,应用到了容差类的两个数值,实际使用时不需要重写这方面的方法
只需设置容差,然后直接判断就OK了
帮助文档中的相关内容
This is an instantiable class that is by default initialized to the default tolerances. Subsequently, the tolerances within it can be customized to suit a specific need. For example, an instance of this class may be specialized for use during surface intersection.
Class Tolerance keeps two properties, EqualPoint and EqualVector, which are used in evaluation according to the following rules:
Two points, p1 and p2, are equal if
(p1 - p2).length() <= equalPoint
Two vectors, v1 and v2, are equal if
(v1 - v2).length() <= equalVector
Two vectors, v1 and v2, are parallel if
(v1/v1.length() - v2/v2.length() ).length() < equalVector
OR
(v1/v1.length() + v2/v2.length() ).length() < equalVector
Two vectors, v1 and v2, are perpendicular if
abs((v1.dotProduct(v2))/(v1.length()*v2.length())) <= equalVector
Two lines or rays are parallel (perpendicular) if their directional vectors are parallel (perpendicular)
 - [CommandMethod("tt")]
- public static void Test()
- {
- var db = HostApplicationServices.WorkingDatabase;
- var doc = Application.DocumentManager.GetDocument(db);
- var ed = doc.Editor;
- Point3d pt1 = new Point3d(0, 0.0001, 0);
- Point3d pt2 = new Point3d(0, 0, 0);
- ed.WriteMessage(
- "\nEqualPoint:{0}\nEqualVector:{1}",
- Tolerance.Global.EqualPoint,
- Tolerance.Global.EqualVector);
- ed.WriteMessage("\npt1 == pt2 is {0}", pt1 == pt2);
- Tolerance oldtol = Tolerance.Global;
- Tolerance.Global = new Tolerance(0.01, 0.01);
- ed.WriteMessage(
- "\nEqualPoint:{0}\nEqualVector:{1}",
- Tolerance.Global.EqualPoint,
- Tolerance.Global.EqualVector);
- ed.WriteMessage("\npt1 == pt2 is {0}", pt1 == pt2);
- Tolerance.Global = oldtol;
- }
命令: tt
EqualPoint:1E-10
EqualVector:1E-12
pt1 == pt2 is False
EqualPoint:0.01
EqualVector:0.01
pt1 == pt2 is True |
|