improved precision for a closest point in SegmentPointDistance

This commit is contained in:
Luigi Malomo 2019-05-13 12:06:08 +02:00
parent b619a09508
commit 3b5464e4a0
1 changed files with 1 additions and 1 deletions

View File

@ -274,7 +274,7 @@ void SegmentPointSquaredDistance( const Segment3<ScalarType> &s,
ScalarType t = ((p-s.P0())*e)/eSquaredNorm; ScalarType t = ((p-s.P0())*e)/eSquaredNorm;
if(t<0) t = 0; if(t<0) t = 0;
else if(t>1) t = 1; else if(t>1) t = 1;
closest = s.P0()+e*t; closest = s.P0() * (1.0 - t) + s.P1() * t;
sqr_dist = SquaredDistance(p,closest); sqr_dist = SquaredDistance(p,closest);
assert(!math::IsNAN(sqr_dist)); assert(!math::IsNAN(sqr_dist));
} }