查看单个帖子
旧 2009-05-06, 08:30 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】odgecircarc2d tangen

odgecircarc2d tangent
odgecircarc2d tangent
the samplepoints() of a tangent (odgeline2d) to odgecircarc2d is returned null.
what is the data present in m_point1, m_point2 of a tangent (odgeline2d) ? can anybody explain...
i have same problem

hi,
tangent of circle is odgeline2d object. odgeline2d is infinite line. it hasn't start and end. it has only point and direction. so if you ask getsamplepoints(int numsample, odgepoint2darray& pointarray),
it return nothing due to odgeline hasn't bounds.
toolkit has odgeline2dseg object - it has start and end point. it is segment representation, but odgeline2d is line representation.
code:
bool odgecircarc2d::tangent(const odgepoint2d& pnt, odgeline2d& line, const odgetol& tol) const
{
if(!odequal(pnt.distanceto(m_pcenter), radius(), tol.equalpoint()))
return false;
odgevector2d v = pnt - m_pcenter;
v.rotateby(odapi2); // anyway, cw or ccw
line.set(pnt, v);
return true;
}
bool odgecircarc2d::tangent(const odgepoint2d& pnt, odgeline2d& line, const odgetol& tol, odgeerror& error) const
{
odgevector2d v = pnt - m_pcenter;
double l = v.length();
if(odequal(l, radius(), tol.equalpoint()))
{
v.rotateby(odapi2); // anyway, cw or ccw
line.set(pnt, v);
error = odge::karg1onthis;
return true;
}
error = ( l < radius() ) ? odge::karg1insidethis : odge::karg1toobig;
return false;
}
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)