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:
apurvapriyadarshi 2023-09-20 15:22:19 +05:30 committed by Ilmari Lauhakangas
parent fbf71a4c21
commit 9844a197bf
2 changed files with 5 additions and 2 deletions

View File

@ -21,6 +21,7 @@ import org.mozilla.gecko.util.FloatUtils;
import java.util.Timer;
import java.util.TimerTask;
import java.lang.StrictMath;
/*
* Handles the kinetic scrolling and zooming physics for a layer controller.
@ -543,7 +544,7 @@ class JavaPanZoomController
private float getVelocity() {
float xvel = mX.getRealVelocity();
float yvel = mY.getRealVelocity();
return (float) Math.sqrt(xvel * xvel + yvel * yvel);
return (float) StrictMath.hypot(xvel, yvel);
}
public PointF getVelocityVector() {

View File

@ -11,6 +11,8 @@ import android.graphics.PointF;
import org.json.JSONException;
import org.json.JSONObject;
import java.lang.StrictMath;
public final class PointUtils {
public static PointF add(PointF one, PointF two) {
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. */
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. */