commit | a1e0ef4836f59a9fd5a2b44ecb94c27227e159c6 | [log] [tgz] |
---|---|---|
author | Keisuke Kuroyanagi <ksk@google.com> | Fri Mar 07 13:03:34 2014 +0900 |
committer | Keisuke Kuroyanagi <ksk@google.com> | Fri Mar 07 14:19:52 2014 +0900 |
tree | 11d85eba7dcb21c70ef013b971e0294bd65b0692 | |
parent | 33392248136d030463f5bac15c3cacfde320972c [diff] |
Fix: point to line segment distance can be NaN. Change-Id: I7db6bfea925a0eda82bfb1f7b5e1110b193dabdb
diff --git a/native/jni/src/suggest/core/layout/proximity_info_utils.h b/native/jni/src/suggest/core/layout/proximity_info_utils.h index 6d2c11b..f55ee23 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_utils.h +++ b/native/jni/src/suggest/core/layout/proximity_info_utils.h
@@ -100,6 +100,10 @@ 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;