Bug fixed in the ClosestPoint2Box2 function

This commit is contained in:
Gianpaolo Palma 2011-03-21 17:03:34 +00:00
parent e90c417d2b
commit e3d8489f0f
1 changed files with 17 additions and 17 deletions

View File

@ -338,14 +338,14 @@ Point2<ScalarType> ClosestPoint2Box2(const Point2<ScalarType> &test,
Point2<ScalarType> closest = ClosestPoint(Segs[0], test); Point2<ScalarType> closest = ClosestPoint(Segs[0], test);
ScalarType minDist = (closest-test).Norm(); ScalarType minDist = (closest-test).Norm();
for (int i=0;i<4;i++) for (int i = 1; i < 4; i++)
{ {
Point2<ScalarType> test=ClosestPoint(Segs[i],test); Point2<ScalarType> point = ClosestPoint(Segs[i], test);
ScalarType dist=(closest-test).Norm(); ScalarType dist = (test - point).Norm();
if (dist < minDist) if (dist < minDist)
{ {
minDist = dist; minDist = dist;
closest=test; closest = point;
} }
} }
return closest; return closest;