Loading core/java/android/transition/ArcMotion.java +60 −66 Original line number Diff line number Diff line Loading @@ -199,15 +199,9 @@ public class ArcMotion extends PathMotion { float ex; float ey; if (startY == endY) { ex = (startX + endX) / 2; ey = startY + mMinimumHorizontalTangent * Math.abs(endX - startX) / 2; } else if (startX == endX) { ex = startX + mMinimumVerticalTangent * Math.abs(endY - startY) / 2; ey = (startY + endY) / 2; } else { float deltaX = endX - startX; float deltaY = endY - startY; // hypotenuse squared. float h2 = deltaX * deltaX + deltaY * deltaY; Loading @@ -219,7 +213,8 @@ public class ArcMotion extends PathMotion { float midDist2 = h2 * 0.25f; float minimumArcDist2 = 0; boolean isQuadrant1Or3 = (deltaX * deltaY) > 0; boolean isMovingUpwards = startY > endY; if ((Math.abs(deltaX) < Math.abs(deltaY))) { // Similar triangles bfa and bde mean that (ab/fb = eb/bd) Loading @@ -227,26 +222,26 @@ public class ArcMotion extends PathMotion { // ab = hypotenuse // bd = hypotenuse/2 // fb = deltaY float eDistY = h2 / (2 * deltaY); if (isQuadrant1Or3) { float eDistY = Math.abs(h2 / (2 * deltaY)); if (isMovingUpwards) { ey = endY + eDistY; ex = endX; } else { ey = startY + eDistY; ex = startX; } else { ey = endY - eDistY; ex = endX; } minimumArcDist2 = midDist2 * mMinimumVerticalTangent * mMinimumVerticalTangent; } else { // Same as above, but flip X & Y // Same as above, but flip X & Y and account for negative eDist float eDistX = h2 / (2 * deltaX); if (isQuadrant1Or3) { ex = endX - eDistX; ey = endY; } else { if (isMovingUpwards) { ex = startX + eDistX; ey = startY; } else { ex = endX - eDistX; ey = endY; } minimumArcDist2 = midDist2 * mMinimumHorizontalTangent Loading @@ -270,12 +265,11 @@ public class ArcMotion extends PathMotion { ex = dx + (ratio * (ex - dx)); ey = dy + (ratio * (ey - dy)); } } float controlX1 = (startX + ex) / 2; float controlY1 = (startY + ey) / 2; float controlX2 = (ex + endX) / 2; float controlY2 = (ey + endY) / 2; path.cubicTo(controlX1, controlY1, controlX2, controlY2, endX, endY); float control1X = (startX + ex) / 2; float control1Y = (startY + ey) / 2; float control2X = (ex + endX) / 2; float control2Y = (ey + endY) / 2; path.cubicTo(control1X, control1Y, control2X, control2Y, endX, endY); return path; } } Loading
core/java/android/transition/ArcMotion.java +60 −66 Original line number Diff line number Diff line Loading @@ -199,15 +199,9 @@ public class ArcMotion extends PathMotion { float ex; float ey; if (startY == endY) { ex = (startX + endX) / 2; ey = startY + mMinimumHorizontalTangent * Math.abs(endX - startX) / 2; } else if (startX == endX) { ex = startX + mMinimumVerticalTangent * Math.abs(endY - startY) / 2; ey = (startY + endY) / 2; } else { float deltaX = endX - startX; float deltaY = endY - startY; // hypotenuse squared. float h2 = deltaX * deltaX + deltaY * deltaY; Loading @@ -219,7 +213,8 @@ public class ArcMotion extends PathMotion { float midDist2 = h2 * 0.25f; float minimumArcDist2 = 0; boolean isQuadrant1Or3 = (deltaX * deltaY) > 0; boolean isMovingUpwards = startY > endY; if ((Math.abs(deltaX) < Math.abs(deltaY))) { // Similar triangles bfa and bde mean that (ab/fb = eb/bd) Loading @@ -227,26 +222,26 @@ public class ArcMotion extends PathMotion { // ab = hypotenuse // bd = hypotenuse/2 // fb = deltaY float eDistY = h2 / (2 * deltaY); if (isQuadrant1Or3) { float eDistY = Math.abs(h2 / (2 * deltaY)); if (isMovingUpwards) { ey = endY + eDistY; ex = endX; } else { ey = startY + eDistY; ex = startX; } else { ey = endY - eDistY; ex = endX; } minimumArcDist2 = midDist2 * mMinimumVerticalTangent * mMinimumVerticalTangent; } else { // Same as above, but flip X & Y // Same as above, but flip X & Y and account for negative eDist float eDistX = h2 / (2 * deltaX); if (isQuadrant1Or3) { ex = endX - eDistX; ey = endY; } else { if (isMovingUpwards) { ex = startX + eDistX; ey = startY; } else { ex = endX - eDistX; ey = endY; } minimumArcDist2 = midDist2 * mMinimumHorizontalTangent Loading @@ -270,12 +265,11 @@ public class ArcMotion extends PathMotion { ex = dx + (ratio * (ex - dx)); ey = dy + (ratio * (ey - dy)); } } float controlX1 = (startX + ex) / 2; float controlY1 = (startY + ey) / 2; float controlX2 = (ex + endX) / 2; float controlY2 = (ey + endY) / 2; path.cubicTo(controlX1, controlY1, controlX2, controlY2, endX, endY); float control1X = (startX + ex) / 2; float control1Y = (startY + ey) / 2; float control2X = (ex + endX) / 2; float control2Y = (ey + endY) / 2; path.cubicTo(control1X, control1Y, control2X, control2Y, endX, endY); return path; } }