### Resolve "Performance tuning"

```Closes #1619

See merge request main/Sumatra!1360

sumatra-commit: f7972214e6da520a46d6d184f3d33d539c6c5daa```
parent 59a0ab58
Pipeline #8861 passed with stage
in 4 minutes and 48 seconds
 ... ... @@ -119,8 +119,8 @@ public final class SumatraMath /** * Checks two double values for equality with a small tolerance value * * @param a first value * @param b second value * @param a first value * @param b second value * @param tolerance to use for comparison * @return true, if absolute difference between both values is smaller than or equal to tolerance */ ... ... @@ -146,23 +146,18 @@ public final class SumatraMath /** * Checks if x is a Number between to values (inclusive) * * @param x a value * @param x a value * @param min smaller value * @param max larger value * @return true, if min <= x <= max */ public static boolean isBetween(final double x, final double min, final double max) { boolean result; if (max > min) { result = (x >= min) && (x <= max); } else { result = (x >= max) && (x <= min); return (x >= min) && (x <= max); } return result; return (x >= max) && (x <= min); } ... ... @@ -180,8 +175,8 @@ public final class SumatraMath * Project value to a relative values between 0 and 1 * * @param value the value * @param from the value that corresponds to 0 * @param to the value that corresponds to 1 * @param from the value that corresponds to 0 * @param to the value that corresponds to 1 * @return value in range [0..1] */ public static double relative(final double value, final double from, final double to) ... ... @@ -214,11 +209,10 @@ public final class SumatraMath /** * Solves for the real roots of a quadratic equation with real * coefficients. The quadratic equation is of the form *

*

* ax2 + bx + c = 0 *

*

* * @author AndreR * @param a Coefficient of x2. * @param b Coefficient of x. * @param c Constant coefficient. ... ... @@ -272,12 +266,11 @@ public final class SumatraMath /** * Solves for the real roots of a cubic equation with real * coefficients. The cubic equation is of the form *

*

* ax3 + bx2 + cx + d = 0 *

*

* Source taken from: https://github.com/davidzof/wattzap/blob/master/src/com/wattzap/model/power/Cubic.java * * @author AndreR * @param a3 Coefficient of x3. * @param b2 Coefficient of x2. * @param c1 Coefficient of x. ... ...

 ... ... @@ -202,7 +202,7 @@ public final class CircleMath */ public static boolean isPointInCircle(ICircular circle, IVector2 point, double margin) { return point.distanceToSqr(circle.center()) <= Math.pow(circle.radius() + margin, 2); return point.distanceToSqr(circle.center()) <= SumatraMath.square(circle.radius() + margin); } ... ...
 ... ... @@ -81,4 +81,11 @@ abstract class ALine implements ILineBase IVector2 closestPointOnLine = closestPointOnLine(point); return point.distanceTo(closestPointOnLine); } @Override public double distanceToSqr(final IVector2 point) { IVector2 closestPointOnLine = closestPointOnLine(point); return point.distanceToSqr(closestPointOnLine); } }