Package buildengine.math
Class MathUtils
java.lang.Object
buildengine.math.MathUtils
A hand full of utilities related to math and numbers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
interpolate
(double goal, double current, double deltaTime) Interpolate a positive of negative double, based on a delta time object and goalstatic Vector2f
interpolate
(Vector2f goal, Vector2f current, double deltaTime) Interpolate a positive of negative point, based on a delta time object and goalstatic double
max
(double... numbers) Gets the highest of a number arraystatic double
min
(double... numbers) Gets the lowest of a number arraystatic Vector2f
rotatePoint
(double theta, Vector2f center, Vector2f point) Rotate a point around a center objectstatic Vector2i
rotatePoint
(double theta, Vector2i center, Vector2i point) Rotate a point around a center objectstatic double
round
(double value, int places) Round any double, to a specific number of decimalsstatic float
toFloat
(double value) Safely converts any double/float value to an int.static int
toInt
(double value) Safely converts any double/float value to an int.
-
Method Details
-
round
public static double round(double value, int places) Round any double, to a specific number of decimals- Parameters:
value
- The value to roundplaces
- The number of decimals- Returns:
- The rounded double
-
toInt
public static int toInt(double value) Safely converts any double/float value to an int. Rounds mathematically.- Parameters:
value
- The double/float to convert- Returns:
- The converted int
-
toFloat
public static float toFloat(double value) Safely converts any double/float value to an int. Rounds mathematically.- Parameters:
value
- The double/float to convert- Returns:
- The converted int
-
min
public static double min(double... numbers) Gets the lowest of a number array- Parameters:
numbers
- Array of numbers- Returns:
- The lowest double.
-
max
public static double max(double... numbers) Gets the highest of a number array- Parameters:
numbers
- Array of numbers- Returns:
- The lowest double.
-
rotatePoint
Rotate a point around a center object- Parameters:
theta
- The amount of rotation in thetacenter
- The center pointpoint
- The point to rotate- Returns:
- A new rotated point
-
rotatePoint
Rotate a point around a center object- Parameters:
theta
- The amount of rotation in thetacenter
- The center pointpoint
- The point to rotate- Returns:
- A new rotated point
-
interpolate
public static double interpolate(double goal, double current, double deltaTime) Interpolate a positive of negative double, based on a delta time object and goal- Parameters:
goal
- The goal to interpolate tocurrent
- The current progress toward that goaldeltaTime
- The delta time, or the speed to interpolate with- Returns:
- A new double representing the updated current value
-
interpolate
Interpolate a positive of negative point, based on a delta time object and goal- Parameters:
goal
- The goal to interpolate tocurrent
- The current progress toward that goaldeltaTime
- The delta time, or the speed to interpolate with- Returns:
- A new Vector representing the updated current point
-