From 35f0ea43b34d848178d04b31f3f53a62994331b6 Mon Sep 17 00:00:00 2001 From: Neil Fuller Date: Thu, 2 Oct 2014 16:39:12 +0100 Subject: [PATCH] Remove dependencies on FloatMath See frameworks/base commit 33253a4baa6279f81a73425b49dfb6abe5f5416e for details. Bug: https://code.google.com/p/android/issues/detail?id=36199 Change-Id: Iae56fa116b5e00e78b294073802d48478a2c9eda --- src/com/android/camera/crop/GeometryMathUtils.java | 8 ++++---- src/com/android/camera/ui/PieRenderer.java | 5 ++--- src/com/android/camera/util/CameraUtil.java | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/com/android/camera/crop/GeometryMathUtils.java b/src/com/android/camera/crop/GeometryMathUtils.java index cb5fefe4b..9658ad808 100644 --- a/src/com/android/camera/crop/GeometryMathUtils.java +++ b/src/com/android/camera/crop/GeometryMathUtils.java @@ -102,7 +102,7 @@ public final class GeometryMathUtils { } public static float[] normalize(float[] a) { - float length = (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); + float length = (float) Math.hypot(a[0], a[1]); float[] b = { a[0] / length, a[1] / length }; @@ -111,7 +111,7 @@ public final class GeometryMathUtils { // A onto B public static float scalarProjection(float[] a, float[] b) { - float length = (float) Math.sqrt(b[0] * b[0] + b[1] * b[1]); + float length = (float) Math.hypot(b[0], b[1]); return dotProduct(a, b) / length; } @@ -126,7 +126,7 @@ public final class GeometryMathUtils { float[] p = { point2[0] - point1[0], point2[1] - point1[1] }; - float length = (float) Math.sqrt(p[0] * p[0] + p[1] * p[1]); + float length = (float) Math.hypot(p[0], p[1]); p[0] = p[0] / length; p[1] = p[1] / length; return p; @@ -149,7 +149,7 @@ public final class GeometryMathUtils { } public static float vectorLength(float[] a) { - return (float) Math.sqrt(a[0] * a[0] + a[1] * a[1]); + return (float) Math.hypot(a[0], a[1]); } public static float scale(float oldWidth, float oldHeight, float newWidth, float newHeight) { diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java index f1a5a9a4b..6bace8693 100644 --- a/src/com/android/camera/ui/PieRenderer.java +++ b/src/com/android/camera/ui/PieRenderer.java @@ -30,7 +30,6 @@ import android.graphics.PointF; import android.graphics.RectF; import android.os.Handler; import android.os.Message; -import android.util.FloatMath; import android.view.MotionEvent; import android.view.ViewConfiguration; import android.view.animation.Animation; @@ -379,7 +378,7 @@ public class PieRenderer extends OverlayRenderer } private void layoutLabel(int level) { - int x = mPieCenterX - (int) (FloatMath.sin(mCenterAngle - CENTER) + int x = mPieCenterX - (int) (Math.sin(mCenterAngle - CENTER) * (mArcRadius + (level + 2) * mRadiusInc)); int y = mArcCenterY - mArcRadius - (level + 2) * mRadiusInc; int w = mLabel.getIntrinsicWidth(); @@ -734,7 +733,7 @@ public class PieRenderer extends OverlayRenderer x = x - mPieCenterX; float y1 = mSliceCenterY - getLevel() * mRadiusInc - y; float y2 = mArcCenterY - getLevel() * mRadiusInc - y; - res.y = (float) Math.sqrt(x * x + y2 * y2); + res.y = (float) Math.hypot(x, y2); if (x != 0) { res.x = (float) Math.atan2(y1, x); if (res.x < 0) { diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 708308b63..2f245a34a 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -385,7 +385,7 @@ public class CameraUtil { public static float distance(float x, float y, float sx, float sy) { float dx = x - sx; float dy = y - sy; - return (float) Math.sqrt(dx * dx + dy * dy); + return (float) Math.hypot(dx, dy); } public static int clamp(int x, int min, int max) { -- 2.11.0