几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » AutoCAD二次开发 » ObjectARX(C++)
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


回复
 
主题工具 搜索本主题 显示模式
旧 2009-04-16, 10:49 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】如何判断一个点是否在一条直线上?

如何判断一个点是否在一条直线上?
如何判断一个点是否在一条直线上?
已知点、线,
有无函数可以判断该点是否在这条线段上,
或者求出点到这条线段的距离的函数或者方法
acad::errorstatus
asdkpoly::intersectwith(
const acdbentity* ent,
acdb::intersect inttype,
const acgeplane& projplane,
acgepoint3darray& points,
int /*thisgsmarker*/,
int /*othergsmarker*/) const
{
assertreadenabled();
acad::errorstatus es = acad::eok;
if (ent == null)
return acad::enullentitypointer;
// the idea is to intersect each side of the polygon
// with the given entity and return all the points.
//
// for non-r12-entities, with intersection methods defined,
// we call that method for each of the sides of the polygon.
// for r12-entities, we use the locally defined intersectors,
// since their protocols are not implemented.
//
if (ent->iskindof(acdbline::desc())) {
if ((es = intline(this, acdbline::cast(ent),
inttype, &projplane, points)) != acad::eok)
{
return es;
}
} else if (ent->iskindof(acdbarc::desc())) {
if ((es = intarc(this, acdbarc::cast(ent), inttype,
&projplane, points)) != acad::eok)
{
return es;
}
} else if (ent->iskindof(acdbcircle::desc())) {
if ((es = intcircle(this, acdbcircle::cast(ent),
inttype, &projplane, points)) != acad::eok)
{
return es;
}
} else if (ent->iskindof(acdb2dpolyline::desc())) {
if ((es = intpline(this, acdb2dpolyline::cast(ent),
inttype, &projplane, points)) != acad::eok)
{
return es;
}
} else if (ent->iskindof(acdb3dpolyline::desc())) {
if ((es = intpline(this, acdb3dpolyline::cast(ent),
inttype, &projplane, points)) != acad::eok)
{
return es;
}
} else {
acgepoint3darray vertexarray;
if ((es = getvertices3d(vertexarray))
!= acad::eok)
{
return es;
}
if (inttype == acdb::kextendarg
|| inttype == acdb::kextendboth)
{
inttype = acdb::kextendthis;
}
acdbline *pacadline;
for (int i = 0; i < vertexarray.length() - 1; i++) {
pacadline = new acdbline();
pacadline->setstartpoint(vertexarray[i]);
pacadline->setendpoint(vertexarray[i + 1]);
pacadline->setnormal(normal());
if ((es = ent->intersectwith(pacadline, inttype,
projplane, points)) != acad::eok)
{
delete pacadline;
return es;
}
delete pacadline;
}
// all the points that we selected in this process are on
// the other curve; we are dealing with apparent
// intersection. if the other curve is 3d or is not
// on the same plane as poly, the points are not on
// poly.
//
// in this case, we need to do some more work. project the
// points back onto the plane. they should lie on
// the projected poly. find points on real poly
// corresponding to the projected points.
//
acgepoint3d projpt, planept;
acgepoint3darray pts;
acgeline3d line;

acgeplane polyplane;
acdb:lanarity plnrty;
getplane(polyplane,plnrty);
for (i = 0; i < points.length(); i++) {
// define a line starting from the projpt and
// along the normal. intersect the polygon with
// that line. find all the points and pick the
// one closest to the given point.
//
projpt = points[i].orthoproject(projplane);
line.set(projpt, projplane.normal());
if ((es = intline(this, line, pts))
!= acad::eok)
{
return es;
}
planept = projpt.project(polyplane,
projplane.normal());
points[i] = pts[0];
double length = (planept - pts[0]).length();
double length2;
for (int j = 1; j < pts.length(); j++) {
if ((length2 = (planept - pts[j]).length())
< length)
{
points[i] = pts[j];
length = length2;
}
}
}
}
return es;
}

已知点、线求距离
double length;
acgepoint2d pt;
acgecurve2d *ent2d;
length = ent2d->distanceto(pt,acgecontext::gtol);
我想用distanceto(pt,acgecontext::gtol);来计算距离
可是我的线,点都是acdb类型的不能用
如何才能将acdb类型的线,点转化为acge类型呢?
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
回复


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 07:41 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多