Fix: point to line segment distance can be NaN.
Change-Id: I7db6bfea925a0eda82bfb1f7b5e1110b193dabdb
This commit is contained in:
parent
3339224813
commit
a1e0ef4836
1 changed files with 4 additions and 0 deletions
|
@ -100,6 +100,10 @@ class ProximityInfoUtils {
|
|||
const float dotProduct = ray1x * ray2x + ray1y * ray2y;
|
||||
const float lineLengthSqr = GeometryUtils::SQUARE_FLOAT(ray2x)
|
||||
+ GeometryUtils::SQUARE_FLOAT(ray2y);
|
||||
if (lineLengthSqr <= 0.0f) {
|
||||
// Return point to the point distance.
|
||||
return getSquaredDistanceFloat(x, y, x1, y1);
|
||||
}
|
||||
const float projectionLengthSqr = dotProduct / lineLengthSqr;
|
||||
|
||||
float projectionX;
|
||||
|
|
Loading…
Reference in a new issue