Fix bug in calculating path in ArcMotion

Bug: 73077523

When the path is perfectly horizontal, ArcMotion
was calculating a Path that had NaN values. This
corrects that problem by special casing horizontal
and vertical paths.

Test: manual with app that discovered the problem
Test: manual with test app
Test: I30d51206194e3c68ea145d3a81e05a461c4e0ca8
Change-Id: Ic1a70b79290847726fc7994d1224fd77024e0610
This commit is contained in:
George Mount
2018-02-07 12:38:47 -08:00
parent 1204a6fd93
commit 575ffb856e

View File

@@ -216,7 +216,13 @@ public class ArcMotion extends PathMotion {
boolean isMovingUpwards = startY > endY;
if ((Math.abs(deltaX) < Math.abs(deltaY))) {
if (deltaY == 0) {
ex = dx;
ey = dy + (Math.abs(deltaX) * 0.5f * mMinimumHorizontalTangent);
} else if (deltaX == 0) {
ex = dx + (Math.abs(deltaY) * 0.5f * mMinimumVerticalTangent);
ey = dy;
} else if ((Math.abs(deltaX) < Math.abs(deltaY))) {
// Similar triangles bfa and bde mean that (ab/fb = eb/bd)
// Therefore, eb = ab * bd / fb
// ab = hypotenuse
@@ -254,7 +260,7 @@ public class ArcMotion extends PathMotion {
float maximumArcDist2 = midDist2 * mMaximumTangent * mMaximumTangent;
float newArcDistance2 = 0;
if (arcDist2 < minimumArcDist2) {
if (arcDist2 != 0 && arcDist2 < minimumArcDist2) {
newArcDistance2 = minimumArcDist2;
} else if (arcDist2 > maximumArcDist2) {
newArcDistance2 = maximumArcDist2;