Commit c0dd3adf authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Remove dependencies on FloatMath"

parents d0927687 35f0ea43
......@@ -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) {
......
......@@ -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) {
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment