public class MathUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static Vector3 |
calcNormal(Vector3[] points) |
static double |
clamp(double val,
double min,
double max)
Clamp value to range [min, max]
|
static int |
findIntersection(Vector2 p0,
Vector2 d0,
Vector2 p1,
Vector2 d1,
Vector2[] results) |
static boolean |
pointInsideTriangle(Vector2 p,
Vector2 p0,
Vector2 p1,
Vector2 p2)
Check if point p is inside triangle (p0, p1, p2)
|
static Vector2 |
rayIntersect(Vector2 origin,
Vector2 dir,
Vector2 a,
Vector2 b)
Check if ray (origin, dir) intersects with line segment(start, end)
|
static double |
toDegree(double radian)
Convert a number from radian to degree
|
static Vector3 |
toDegree(double x,
double y,
double z)
Convert a number from radian to degree
|
static float |
toDegree(float radian)
Convert a number from radian to degree
|
static Vector3 |
toDegree(Vector3 radian)
Convert a
Vector3 from radian to degree. |
static double |
toRadian(double degree)
Convert a number from degree to radian
|
static Vector3 |
toRadian(double x,
double y,
double z)
Convert a vector from degree to radian
|
static float |
toRadian(float degree)
Convert a number from degree to radian
|
static Vector3 |
toRadian(Vector3 degree)
Convert a
Vector3 from degree to radian |
public static double clamp(double val,
double min,
double max)
val - Value to clamp.min - Minimum value.max - Maximum value.
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);
public static Vector3 toDegree(Vector3 radian)
Vector3 from radian to degree.radian - The radian value.
Vector3 degrees = MathUtils.toDegree(new Vector3(0.34, 0.9, 0.2));
System.out.printf("Degrees = %s", degrees);
public static Vector3 toRadian(Vector3 degree)
Vector3 from degree to radiandegree - The degree value.
Vector3 radians = MathUtils.toRadian(new Vector3(90, 134, 0));
System.out.printf("Radians = %s", radians);
public static float toDegree(float radian)
radian - The radian value.
var deg = MathUtils.toDegree(0.3f);
System.out.printf("Degrees = %s", deg);
public static double toDegree(double radian)
radian - The radian value.
var deg = MathUtils.toDegree(0.3);
System.out.printf("Degrees = %s", deg);
public static Vector3 toDegree(double x, double y, double z)
x - The x component in radian value.y - The y component in radian value.z - The z component in radian value.public static float toRadian(float degree)
degree - The degree value.
var rad = MathUtils.toRadian(0.3);
System.out.printf("Radian = %d", rad);
public static double toRadian(double degree)
degree - The degree value.
var rad = MathUtils.toRadian(0.3);
System.out.printf("Radian = %d", rad);
public static Vector3 toRadian(double x, double y, double z)
x - The x component in degree value.y - The y component in degree value.z - The z component in degree value.public static int findIntersection(Vector2 p0, Vector2 d0, Vector2 p1, Vector2 d1, Vector2[] results)
public static boolean pointInsideTriangle(Vector2 p, Vector2 p0, Vector2 p1, Vector2 p2)