MathUtils
Inheritance: java.lang.Object
public class MathUtils
A set of useful mathematical utilities.
Methods
Method | Description |
---|---|
clamp(double val, double min, double max) | Clamp value to range [min, max] |
equals(Object arg0) | |
getClass() | |
hashCode() | |
notify() | |
notifyAll() | |
toDegree(Vector3 radian) | Convert a Vector3 from radian to degree. |
toDegree(double radian) | Convert a number from radian to degree |
toDegree(double x, double y, double z) | Convert a number from radian to degree |
toDegree(float radian) | Convert a number from radian to degree |
toRadian(Vector3 degree) | Convert a Vector3 from degree to radian |
toRadian(double degree) | Convert a number from degree to radian |
toRadian(double x, double y, double z) | Convert a vector from degree to radian |
toRadian(float degree) | Convert a number from degree to radian |
toString() | |
wait() | |
wait(long arg0) | |
wait(long arg0, int arg1) |
clamp(double val, double min, double max)
public static double clamp(double val, double min, double max)
Clamp value to range [min, max]
Parameters:
Parameter | Type | Description |
---|---|---|
val | double | Value to clamp. |
min | double | Minimum value. |
max | double | Maximum value. |
Returns: double - The value between [min, max] Example:
double val = 195;
//Clamp value to [0, 100]
double clampedValue = MathUtils.clamp(val, 0, 100);
//This will output 100
System.out.printf("Value = %d", val);
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
hashCode()
public native int hashCode()
Returns: int
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
toDegree(Vector3 radian)
public static Vector3 toDegree(Vector3 radian)
Convert a Vector3 from radian to degree.
Parameters:
Parameter | Type | Description |
---|---|---|
radian | Vector3 | The radian value. |
Returns: Vector3 - The degree value. Example:
Vector3 degrees = MathUtils.toDegree(new Vector3(0.34, 0.9, 0.2));
System.out.printf("Degrees = %s", degrees);
toDegree(double radian)
public static double toDegree(double radian)
Convert a number from radian to degree
Parameters:
Parameter | Type | Description |
---|---|---|
radian | double | The radian value. |
Returns: double - The degree value. Example:
var deg = MathUtils.toDegree(0.3);
System.out.printf("Degrees = %s", deg);
toDegree(double x, double y, double z)
public static Vector3 toDegree(double x, double y, double z)
Convert a number from radian to degree
Parameters:
Parameter | Type | Description |
---|---|---|
x | double | The x component in radian value. |
y | double | The y component in radian value. |
z | double | The z component in radian value. |
Returns: Vector3 - The degree value.
toDegree(float radian)
public static float toDegree(float radian)
Convert a number from radian to degree
Parameters:
Parameter | Type | Description |
---|---|---|
radian | float | The radian value. |
Returns: float - The degree value. Example:
var deg = MathUtils.toDegree(0.3f);
System.out.printf("Degrees = %s", deg);
toRadian(Vector3 degree)
public static Vector3 toRadian(Vector3 degree)
Convert a Vector3 from degree to radian
Parameters:
Parameter | Type | Description |
---|---|---|
degree | Vector3 | The degree value. |
Returns: Vector3 - The radian value. Example:
Vector3 radians = MathUtils.toRadian(new Vector3(90, 134, 0));
System.out.printf("Radians = %s", radians);
toRadian(double degree)
public static double toRadian(double degree)
Convert a number from degree to radian
Parameters:
Parameter | Type | Description |
---|---|---|
degree | double | The degree value. |
Returns: double - The radian value. Example:
var rad = MathUtils.toRadian(0.3);
System.out.printf("Radian = %d", rad);
toRadian(double x, double y, double z)
public static Vector3 toRadian(double x, double y, double z)
Convert a vector from degree to radian
Parameters:
Parameter | Type | Description |
---|---|---|
x | double | The x component in degree value. |
y | double | The y component in degree value. |
z | double | The z component in degree value. |
Returns: Vector3 - The radian value.
toRadian(float degree)
public static float toRadian(float degree)
Convert a number from degree to radian
Parameters:
Parameter | Type | Description |
---|---|---|
degree | float | The degree value. |
Returns: float - The radian value. Example:
var rad = MathUtils.toRadian(0.3);
System.out.printf("Radian = %d", rad);
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |