求两条直线交点时可以使用IntersectWith方法,但对于我这种初学者有点摸不清该怎么使用。
直接上代码吧
[CommandMethod("GTest")]
public static void GTest()
{
var p1 = new Point3d(0, 0, 0);
var p2 = new Point3d(100, 0, 0);
var p3 = new Point3d(100, 100, 0);
var p4 = new Point3d(0, 100, 0);
var line = new Line(p1, p2);//创建直线
var s1 = new Point3d(80, -40, 0);
var s2 = new Point3d(20, 90, 0);
var line2 = new Line(s1, s2);
Point3dCollection pt3Coll = new Point3dCollection();//交点集合
line2.IntersectWith(line, Intersect.ExtendBoth, pt3Coll, IntPtr.Zero, IntPtr.Zero);
if (pt3Coll.Count > 0)//交点集合 2个交点
{
foreach (var jd in pt3Coll)
{
var t = jd;
}
}
pt3Coll = new Point3dCollection();/