tdf#147906 used StrictMath.hypot for Pythagorean addition
Change-Id: I529dc199c2cc20ce91b7181f650c36db8d81fc9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157098 Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
This commit is contained in:
committed by
Ilmari Lauhakangas
parent
fbf71a4c21
commit
9844a197bf
@@ -21,6 +21,7 @@ import org.mozilla.gecko.util.FloatUtils;
|
|||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
import java.lang.StrictMath;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handles the kinetic scrolling and zooming physics for a layer controller.
|
* Handles the kinetic scrolling and zooming physics for a layer controller.
|
||||||
@@ -543,7 +544,7 @@ class JavaPanZoomController
|
|||||||
private float getVelocity() {
|
private float getVelocity() {
|
||||||
float xvel = mX.getRealVelocity();
|
float xvel = mX.getRealVelocity();
|
||||||
float yvel = mY.getRealVelocity();
|
float yvel = mY.getRealVelocity();
|
||||||
return (float) Math.sqrt(xvel * xvel + yvel * yvel);
|
return (float) StrictMath.hypot(xvel, yvel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PointF getVelocityVector() {
|
public PointF getVelocityVector() {
|
||||||
|
@@ -11,6 +11,8 @@ import android.graphics.PointF;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.lang.StrictMath;
|
||||||
|
|
||||||
public final class PointUtils {
|
public final class PointUtils {
|
||||||
public static PointF add(PointF one, PointF two) {
|
public static PointF add(PointF one, PointF two) {
|
||||||
return new PointF(one.x + two.x, one.y + two.y);
|
return new PointF(one.x + two.x, one.y + two.y);
|
||||||
@@ -30,7 +32,7 @@ public final class PointUtils {
|
|||||||
|
|
||||||
/* Computes the magnitude of the given vector. */
|
/* Computes the magnitude of the given vector. */
|
||||||
public static float distance(PointF point) {
|
public static float distance(PointF point) {
|
||||||
return (float)Math.sqrt(point.x * point.x + point.y * point.y);
|
return (float)StrictMath.hypot(point.x, point.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Computes the scalar distance between two points. */
|
/** Computes the scalar distance between two points. */
|
||||||
|
Reference in New Issue
Block a user