Package dev.prozilla.pine.common.math
Class MathUtils
java.lang.Object
dev.prozilla.pine.common.math.MathUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic float
clamp
(float value, float min, float max) Clamps a value between a min and a max value.static int
clamp
(int value, int min, int max) Clamps a value between a min and a max value.static float
cubicBezier
(float t, float p0, float p1, float p2, float p3) Calculates the value of a cubic Bézier function based on given control points.static float
lerp
(float start, float end, float step) Linear interpolation between two values.static float
remap
(float value, float x, float y, float a, float b) Remaps a float value from one range to another.
-
Constructor Details
-
MathUtils
public MathUtils()
-
-
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
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 float 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
-
cubicBezier
public static float cubicBezier(float t, float p0, float p1, float p2, float p3) Calculates the value of a cubic Bézier function based on given control points.- Parameters:
p0
- X coordinate of first control pointp1
- Y coordinate of first control pointp2
- X coordinate of second control pointp3
- Y coordinate of second control point
-