java.lang.Object
technology.sola.math.SolaMath
SolaMath is a collection of static math functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
clamp
(float min, float max, float value) Clamps a float value between a min and max.static Vector2D
Clamps aVector2D
between a min and max.static int
fastRound
(float value) Rounds a positive float value to the nearest integer quickly.static float
lerp
(float start, float end, float percent) Linearly interpolates a value between start and end.static float
lerp
(float start, float end, float percent, EasingFunction easingFunction) Interpolates a value between start and end via desiredEasingFunction
.static Vector2D
Linearly interpolates aVector2D
value between start and end.static Vector2D
lerp
(Vector2D start, Vector2D end, float percent, EasingFunction easingFunction) Interpolates aVector2D
value between start and end via desiredEasingFunction
.
-
Method Details
-
lerp
public static float lerp(float start, float end, float percent) Linearly interpolates a value between start and end.- Parameters:
start
- the minimum value to returnend
- the maximum value to returnpercent
- the "progress" towards the end value- Returns:
- the linearly interpolated value clamped between start and end
-
lerp
Interpolates a value between start and end via desiredEasingFunction
.- Parameters:
start
- the minimum value to returnend
- the maximum value to returnpercent
- the "progress" towards the end valueeasingFunction
- theEasingFunction
used during interpolation- Returns:
- the interpolated value clamped between start and end
-
lerp
Linearly interpolates aVector2D
value between start and end.- Parameters:
start
- the minimum value to returnend
- the maximum value to returnpercent
- the "progress" towards the end value- Returns:
- the linearly interpolated vector clamped between start and end
-
lerp
public static Vector2D lerp(Vector2D start, Vector2D end, float percent, EasingFunction easingFunction) Interpolates aVector2D
value between start and end via desiredEasingFunction
.- Parameters:
start
- the minimum value to returnend
- the maximum value to returnpercent
- the "progress" towards the end valueeasingFunction
- theEasingFunction
used during interpolation- Returns:
- the interpolated vector clamped between start and end
-
clamp
public static float clamp(float min, float max, float value) Clamps a float value between a min and max.- Parameters:
min
- the minimum valuemax
- the maximum valuevalue
- the value to clamp- Returns:
- the clamped value
-
clamp
Clamps aVector2D
between a min and max.- Parameters:
min
- the minimum valuemax
- the maximum valuevalue
- the value to clamp- Returns:
- the clamped
Vector2D
-
fastRound
public static int fastRound(float value) Rounds a positive float value to the nearest integer quickly.- Parameters:
value
- the float value to round- Returns:
- the rounded value
-