关于求空间两曲线交点的体会!
www.dimcax.com
关于求空间两曲线交点的体会!
空间两条曲线求交点: c1为curve已知 c1为curve已知 point3dcollection m_ints = new point3dcollection(); 如果两曲线均不为三维多段线或则两曲线均为三维多段线,则有: c1.intersectwith(c2,intersect.onbothoperands, new plane(),m_ints, 0, 0);得出的所有交点在c1曲线上 c2.intersectwith(c1,intersect.onbothoperands, new plane(),m_ints, 0, 0);得出的所有交点在c2曲线上 如果两曲线有一条为三维多段线(c1),而另一条不是三维多段线(c2),则:不管是个用c1.intersectwith(c2,...)还是用c2.intersectwith(c1,...)得到的交点均在c2曲线上 欢迎讨论! [commandmethod("mtest")] public void test() { editor m_ed = application.documentmanager.mdiactivedocument.editor; database m_db = hostapplicationservices.workingdatabase; promptentityoptions m_peo=new promptentityoptions("\n请选择第一条曲线:"); promptentityresult m_per=m_ed.getentity(m_peo); if (m_per.status != promptstatus.ok) { return; } objectid m_objid1 = m_per.objectid; m_peo = new promptentityoptions("\n请选择第二条曲线:"); m_per = m_ed.getentity(m_peo); if (m_per.status != promptstatus.ok) { return; } objectid m_objid2 = m_per.objectid; using (transaction m_tr = m_db.transactionmanager.starttransaction()) { curve m_cur1 = (curve)m_tr.getobject(m_objid1, openmode.forread); curve m_cur2 = (curve)m_tr.getobject(m_objid2, openmode.forread); point3dcollection m_ints = new point3dcollection(); m_cur1.intersectwith(m_cur2, intersect.onbothoperands,new plane(), m_ints, 0, 0); foreach (point3d m_pt in m_ints) { m_ed.writemessage("\n第一条曲线与第二条曲线交点:{0}", m_pt); } m_ed.writemessage("\n==="); m_ints.clear(); m_cur2.intersectwith(m_cur1, intersect.onbothoperands, new plane(), m_ints, 0, 0); foreach (point3d m_pt in m_ints) { m_ed.writemessage("\n第二条曲线与第条曲线一交点:{0}", m_pt); } m_tr.commit(); } } [
对于下面的说法:
如果两曲线有一条为三维多段线(c1),而另一条不是三维多段线(c2),则:不管是个用c1.intersectwith(c2,...)还是用c2.intersectwith(c1,...)得到的交点均在c2曲线上
有不同看法,不知道你说的三维多段线(c1)是不是高程全为0,不然怎么会有交点呢? 如果三维c1有高程,另一条二维c2没有高程的话,求交点还是很麻烦的
..........
也可以求非同一平面的曲线交点的,上面的例子就可以.你只要指定一个投影平面就可以. lz说的交点在曲线上,我还是不理解,交点只是个坐标值而已,应该属于两条线共有的,只是z值属于你指定的投影平面的
"如果三维c1有高程,另一条二维c2没有高程的话,求交点还是很麻烦的" 你试试我上面的代码,我说的就是z值不同的空间交点
.........
你说的高程是指elevation么,如果是这个那即使不在同一平面也可以求虚交点.不是的话,对于polyline3d的实现可以将z坐标设为0来求,完后再设回去
.............
我在空间地形线求交点时试过.用net写的方法简明,直接使用intersectwith函数就可以了.在vlisp中我看到的相似的代码是将z值设为零来实现的
学习中........