Package dev.prozilla.pine.common.math
Class MathUtils
java.lang.Object
dev.prozilla.pine.common.math.MathUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic floatclamp(float value, float min, float max) Clamps a value between a min and a max value.static intclamp(int value, int min, int max) Clamps a value between a min and a max value.static floatcubicBezier(float t, float x1, float y1, float x2, float y2) Calculates the value of a cubic Bézier function based on given control points.static StringfloatToString(float value) static booleanisRound(float value) static booleanisValidInteger(String string) static floatlerp(float start, float end, float step) Linear interpolation between two values.static doublemax(double[] values) static floatmax(float... values) static floatmin(float... values) static voidnormalize(double[] values) static floatremap(float value, float a, float b) Remaps a float value between0fand1f.static floatremap(float value, float x, float y, float a, float b) Remaps a float value from one range to another.static floatRemaps a float value between0fand1f.
-
Method Details
-
clamp
public static float clamp(float value, float min, float max) Clamps a value between a min and a max value.- Parameters:
value- Valuemin- Min valuemax- Max value- Returns:
- Clamped value
-
clamp
public static int clamp(int value, int min, int max) Clamps a value between a min and a max value.- Parameters:
value- Valuemin- Min valuemax- Max value- Returns:
- Clamped value
-
lerp
public static float lerp(float start, float end, float step) Linear interpolation between two values.- Parameters:
start- Start valueend- End valuestep- Amount to interpolate (between 0f and 1f)- Returns:
- Interpolated value between start and value
-
remap
Remaps a float value between0fand1f.- Parameters:
value- The input value to remap- Returns:
- The remapped value in the range [a, b]
-
remap
public static float remap(float value, float a, float b) Remaps a float value between0fand1f.- Parameters:
value- The input value to remapa- The lower bound of the target rangeb- The upper bound of the target range- Returns:
- The remapped value in the range [a, b]
-
remap
public static float remap(float value, float x, float y, float a, float b) throws IllegalArgumentException Remaps a float value from one range to another.- Parameters:
value- The input value to remapx- The lower bound of the original rangey- The upper bound of the original rangea- The lower bound of the target rangeb- The upper bound of the target range- Returns:
- The remapped value in the range [a, b]
- Throws:
IllegalArgumentException
-
normalize
public static void normalize(double[] values) -
min
public static float min(float... values) -
max
public static float max(float... values) -
max
public static double max(double[] values) -
cubicBezier
public static float cubicBezier(float t, float x1, float y1, float x2, float y2) Calculates the value of a cubic Bézier function based on given control points.- Parameters:
x1- X coordinate of first control pointy1- Y coordinate of first control pointx2- X coordinate of second control pointy2- Y coordinate of second control point
-
isValidInteger
-
floatToString
-
isRound
public static boolean isRound(float value)
-