Class MathUtil
java.lang.Object
io.github.tigerbotics7125.tigerlib.util.MathUtil
Math formulas.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
distance
(double x1, double x2) static double
distance
(double x1, double y1, double x2, double y2) static double
distance
(double x1, double y1, double z1, double x2, double y2, double z2) static double
minMaxScaling
(double x, double oldMin, double oldMax, double newMin, double newMax) Changes the scale of a value from one range to another.static boolean
pnpoly
(int numVerts, double[] vertXs, double[] vertYs, double testX, double testY) Generic PNPOLY algo for doubles.static boolean
pnpoly
(int numVerts, int[] vertXs, int[] vertYs, double testX, double testY) Generic PNPOLY algo for ints.
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
minMaxScaling
public static double minMaxScaling(double x, double oldMin, double oldMax, double newMin, double newMax) Changes the scale of a value from one range to another.- Parameters:
x
- inputoldMin
- initial lower bounderyoldMax
- initial upper bounderynewMin
- new lower bounderynewMax
- new upper boundery- Returns:
- x scaled from old to new.
-
pnpoly
public static boolean pnpoly(int numVerts, double[] vertXs, double[] vertYs, double testX, double testY) Generic PNPOLY algo for doubles.- Parameters:
numVerts
- Number of verticies.vertXs
- Static array of vertex x points.vertYs
- Static array of vertex y points.testX
- Test point X value.testY
- Test point Y value.- Returns:
- Wheter the supplied (x, y) coordinate lies within the supplied polygon.
-
pnpoly
public static boolean pnpoly(int numVerts, int[] vertXs, int[] vertYs, double testX, double testY) Generic PNPOLY algo for ints.- Parameters:
numVerts
- Number of verticies.vertXs
- Static array of vertex x points.vertYs
- Static array of vertex y points.testX
- Test point X value.testY
- Test point Y value.- Returns:
- Wheter the supplied (x, y) coordinate lies within the supplied polygon.
-
distance
public static double distance(double x1, double x2) - Parameters:
x1
-x2
-- Returns:
- The Euclidean distance between two points in 1D space.
-
distance
public static double distance(double x1, double y1, double x2, double y2) - Parameters:
x1
-y1
-x2
-y2
-- Returns:
- The Euclidean distance between two points in 2D space.
-
distance
public static double distance(double x1, double y1, double z1, double x2, double y2, double z2) - Parameters:
x1
-y1
-z1
-x2
-y2
-z2
-- Returns:
- The Euclidean distance between two points in 3D space.
-