Package org.eclipse.mosaic.lib.math
Class MathUtils
java.lang.Object
org.eclipse.mosaic.lib.math.MathUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleangleDif(double a, double b) static doubleangleDifDeg(double a, double b) static doubleclamp(double d, double min, double max) static floatclamp(float d, float min, float max) static intclamp(int i, int min, int max) static intgcd(int a, int b) Returns the greatest common divisor of a and b (e.g.static booleanisFuzzyEqual(double a, double b) static booleanisFuzzyEqual(double a, double b, double epsilon) static booleanisFuzzyEqual(float a, float b) static booleanisFuzzyEqual(float a, float b, float epsilon) static booleanisFuzzyZero(double a) static booleanisFuzzyZero(float a) static doublemax(double a, double b, double c) static floatmax(float a, float b, float c) static doublemin(double a, double b, double c) static floatmin(float a, float b, float c) static doublenormalizeDegree(double deg) static booleanpnpoly(int nvert, float[] vertx, float[] verty, float testx, float testy) Point Inclusion in Polygon Test.static doublewrapAnglePiPi(double a) static floatwrapAnglePiPi(float a)
-
Field Details
-
EPSILON_D
public static final double EPSILON_D- See Also:
-
EPSILON_F
public static final float EPSILON_F- See Also:
-
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
Method Details
-
isFuzzyZero
public static boolean isFuzzyZero(float a) -
isFuzzyZero
public static boolean isFuzzyZero(double a) -
isFuzzyEqual
public static boolean isFuzzyEqual(float a, float b) -
isFuzzyEqual
public static boolean isFuzzyEqual(float a, float b, float epsilon) -
isFuzzyEqual
public static boolean isFuzzyEqual(double a, double b) -
isFuzzyEqual
public static boolean isFuzzyEqual(double a, double b, double epsilon) -
clamp
public static float clamp(float d, float min, float max) -
clamp
public static double clamp(double d, double min, double max) -
clamp
public static int clamp(int i, int min, int max) -
wrapAnglePiPi
public static float wrapAnglePiPi(float a) -
wrapAnglePiPi
public static double wrapAnglePiPi(double a) -
angleDif
public static double angleDif(double a, double b) -
angleDifDeg
public static double angleDifDeg(double a, double b) -
normalizeDegree
public static double normalizeDegree(double deg) -
max
public static float max(float a, float b, float c) -
min
public static float min(float a, float b, float c) -
max
public static double max(double a, double b, double c) -
min
public static double min(double a, double b, double c) -
gcd
public static int gcd(int a, int b) Returns the greatest common divisor of a and b (e.g.gcd(12, 18) = 6)- Parameters:
a- first numberb- second number- Returns:
- greatest common divisor of a and b.
-
pnpoly
public static boolean pnpoly(int nvert, float[] vertx, float[] verty, float testx, float testy) Point Inclusion in Polygon Test. Defines if a points lies within a polygon- Parameters:
nvert- Number of vertices in the polygon. Whether to repeat the first vertex at the end is discussed below.vertx- Array containing the x-coordinates of the polygon's vertices.verty- Array containing the y-coordinates of the polygon's vertices.testx- X-coordinate of the test point.testy- Y-coordinate of the test point.- Returns:
- true if point lies within the polygon, false otherwise
-