![]() |
【转帖】怎样得到多段线上一点处的曲率?
怎样得到多段线上一点处的曲率?
www.dimcax.com 怎样得到多段线上一点处的曲率? 请教高手,怎样得到多段线上一点处的曲率? 什么函数可以实现呢 最好有c#的代码。 呵呵,不胜感激! 我也曾经疑惑过很长时间。看看下面代码吧:vbnet的,自己转下。 <commandmethod("testcut")> _ public sub cut() dim db as database = hostapplicationservices.workingdatabase dim ed as editor = application.documentmanager.mdiactivedocument.editor dim ts as string = vbcr & "请选择线条(圆弧、直线或者多义线):" dim opt as new promptentityoptions(ts) opt.setrejectmessage(vbcr & "只能线条") opt.addallowedclass(gettype(polyline), true) opt.addallowedclass(gettype(arc), true) opt.addallowedclass(gettype(line), true) dim res as promptentityresult = ed.getentity(opt) if res.status <> promptstatus.ok then ed.writemessage("用户自行退出!" & vbcr) else '获取等分数 dim iop as new promptintegeroptions("指定等分段的数量:") iop.defaultvalue = 10 dim irt as promptintegerresult = ed.getinteger(iop) dim n as integer if irt.status <> promptstatus.ok orelse irt.value < 2 then return else n = irt.value end if dim entid as objectid = res.objectid using trans as transaction = db.transactionmanager.starttransaction() '得到拾取的对象 dim ent as entity = trans.getobject(entid, openmode.forread) dim cv as curve = directcast(trans.getobject(ent.objectid, openmode.forwrite), curve) dim len as double = cv.getdistanceatparameter(cv.endparam) dim i as integer for i = 0 to n dim p as point3d = cv.getpointatdist(i * len / n) dim kp as object = cv.getfirstderivative(cv.getparameteratdistance(i * len / n)) dim ka as double = kp(1) / kp(0) - math.pi / 2 call addtext(p, "等分点" & cstr(i), 3, ka, 1, 1) next trans.commit() end using end if end sub ' 由插入点、文字内容、文字高度和倾斜角度创建单行文字的函数. public function addtext(byval position as point3d, byval textstring as string, byval height as double, byval rotate as double, byval dq as integer, byval co as integer) as objectid 'position为文字位置,textstring为文字内容,height为文字高度,rotate为文字角度,dq为对齐方式,co为颜色 try dim ent as new dbtext() ent.position = position ent.textstring = textstring ent.height = height ent.rotation = rotate ent.colorindex = co select case dq case 0 ent.horizontalmode = texthorizontalmode.textmid case 1 ent.horizontalmode = texthorizontalmode.textleft ent.verticalmode = textverticalmode.textverticalmid end select ent.alignmentpoint = position dim entid as objectid = appendentity(ent) return entid catch ' 创建失败,则返回一个空的objectid. dim nullid as objectid = objectid.null return nullid end try end function ' 将图形对象加入到模型空间的函数. public function appendentity(byval ent as entity) as objectid dim db as database = hostapplicationservices.workingdatabase dim entid as objectid using trans as transaction = db.transactionmanager.starttransaction dim bt as blocktable = trans.getobject(db.blocktableid, openmode.forread) dim btr as blocktablerecord = trans.getobject(bt(blocktablerecord.modelspace), openmode.forwrite) entid = btr.appendentity(ent) trans.addnewlycreateddbobject(ent, true) trans.commit() end using return entid end function 谢谢热心肠的ntchjie先生,我试试看... |
| 所有的时间均为北京时间。 现在的时间是 01:04 AM. |