第一次使用这个类,
起初以为这个BoundedPlane 是三角形,
没想到在求取交点时,
有交点位于三角形之外,
在QQ群193522571中请教,
群友45168391告诉我BoundedPlane是平行四边形,
不是三角形,
并且告诉我需要对对加过进行判断,
或者简单的求两次,
用不同的BoundedPlane的来求,
都能得到交点,
交点必然在三角形之中。
Point3d p1 = new Point3d(); Point3d p2 = new Point3d(3, 0, 0); Point3d p3 = new Point3d(1, 3, 0); Point3d p4 = new Point3d(3, 2, 0); Point3d p5 = new Point3d(3, 2, 1); Point3d p6 = new Point3d(3, 4, 0); Point3d p7 = new Point3d(3, 4, 1); BoundedPlane bp1 = new BoundedPlane(p1, p2, p3); BoundedPlane bp2 = new BoundedPlane(p2, p3, p1); BoundedPlane bp3 = new BoundedPlane(p3, p1, p2); var l1 = new LineSegment3d(p4, p5); var l2 = new LineSegment3d(p6, p7); var pts11 = l1.IntersectWith(bp1); var pts12 = l1.IntersectWith(bp2); var pts13 = l1.IntersectWith(bp3); var pts21 = l2.IntersectWith(bp1); var pts22 = l2.IntersectWith(bp2); var pts23 = l2.IntersectWith(bp3); if (pts11 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp11交点个数为:" + pts11.Length); } if (pts12 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp12交点个数为:" + pts12.Length); } if (pts13 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp13交点个数为:" + pts13.Length); } if (pts21 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp21交点个数为:" + pts21.Length); } if (pts22 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp22交点个数为:" + pts22.Length); } if (pts23 != null) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("bp23交点个数为:" + pts23.Length); }
这几天比较忙,
没有时间进行一步研究,
只能简单记录一下,
有遇到类似问题的朋友可以继续研究一下。
标签:AutoCAD,Geometry,BoundedPlane,交点,var,new,Point3d From: https://www.cnblogs.com/myzw/p/16736709.html