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
easeOutQuad
(float time) 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
-
easeOutQuad
public static float easeOutQuad(float time)
-