|
高级会员
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
|
【转帖】odgeline3dclosestpointto90 not working
odgeline3d::closestpointto() not working
odgeline3d::closestpointto() not working
hi,
in the examples cpp file odcurvefunction.cpp function closestpointto is used.
code:
odresult oddbcurvepe_line::getclosestpointto(const oddbcurve* curve,
const odgepoint3d& givenpoint,
odgepoint3d& pointoncurve,
bool extend ) const
{
....
else if ( extend )
pointoncurve = odgeline3d(p1,p2).closestpointto(givenpoint);
else
pointoncurve = odgelineseg3d(p1,p2).closestpointto(givenpoint);
return eok;
}
but when i am using the function closestpointto() for odgeline3d.. its crashing saying "not implement".. if it still implement then that sudn't be used in example file.. or i am doing somthing wrong...
my code is.....
code:
oddbxlineptr xline = (oddbxlineptr)m_poddbentity;
odgepoint3d basepoint = xline->basepoint();
odgevector3d unitdir = xline->unitdir();
odgepoint3d secondpoint( basepoint.x - unitdir.x, basepoint.y - unitdir.y, basepoint.z - unitdir.z);
odgeline3d line( basepoint, secondpoint);
pointoncurve = line.closestpointto(givenpoint);
can anybody tell... what i m doing wrong.. i want to calculate the closest point for an infinite line..
thanks.......
.................................................. .........................
you are right. odgeline3d::closestpointto is not implemented.
(it seems that 'extend' case was not tested, in that sample)
you may easily implement oddbcurvepe_line::getclosestpointto otherwise, e.g. like this:
code:
...
else if (extend)
{
odgevector3d v = (p2 - p1).normal();
pointoncurve = p1 + v * v.dotproduct(givenpoint - p1)
}
...
vladimir
thank you for the reply....
.................................................. .........................
|