【发布时间】:2015-08-11 18:12:00
【问题描述】:
如何从确定的点看凸多边形的极值点?我试图通过点角度来做这个,越来越小的角度是极值点,但是当观察者更接近点时,这是无效的。
这是我的代码:
Vec2* bigger = &points[0]; // pointer to point with bigger angle
Vec2* smaller = &points[0]; // pointer to point with smaller angle
Vec2 observer = rayCenter;
// iterate through all points of polygon
for(unsigned u = 0 ; u < points.size() ; u++)
{
Vec2 distance = observer - points[u];
if(distance.angle() < (observer - *smaller).angle())
smaller = &points[u];
if(distance.angle() > (observer - *bigger).angle())
bigger = &points[u];
}
结果:
其中蓝线是排除点和黄色理想点。 有没有解决这个问题的最佳方法?
对不起我的英语。
【问题讨论】: