Class MathHelper
java.lang.Object
com.marginallyclever.convenience.helpers.MathHelper
Math methods.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
equals
(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double v) compare two vectorsstatic long
gcd
(long a, long b) greatest common dividerstatic double
interpolate
(double a, double b, double t) interpolate from a to bstatic float
interpolate
(float a, float b, double t) interpolate from a to bstatic javax.vecmath.Point3d
interpolate
(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double t) interpolate from start to endstatic javax.vecmath.Vector3d
interpolate
(javax.vecmath.Vector3d start, javax.vecmath.Vector3d end, double t) interpolate from start to endstatic long
lcm
(long a, long b) least common multiplierstatic double[]
quatToEuler
(javax.vecmath.Quat4d q) Convert quaternion 'q' to euler radian angles roll, pitch, yawstatic javax.vecmath.Vector3d
slerp
(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double t) Spherical linear interpolation between two vectors.
-
Field Details
-
EPSILON
public static final double EPSILON- See Also:
-
TWOPI
public static final double TWOPI- See Also:
-
-
Constructor Details
-
MathHelper
public MathHelper()
-
-
Method Details
-
gcd
public static long gcd(long a, long b) greatest common divider- Parameters:
a
-b
-- Returns:
- greatest common divider
-
lcm
public static long lcm(long a, long b) least common multiplier- Parameters:
a
-b
-- Returns:
- least common multiplier
-
interpolate
public static float interpolate(float a, float b, double t) interpolate from a to b- Parameters:
a
-b
-t
- [0...1]- Returns:
- a + (b-a)*t
-
interpolate
public static double interpolate(double a, double b, double t) interpolate from a to b- Parameters:
a
-b
-t
- [0...1]- Returns:
- a + (b-a)*t
-
interpolate
public static javax.vecmath.Vector3d interpolate(javax.vecmath.Vector3d start, javax.vecmath.Vector3d end, double t) interpolate from start to end- Parameters:
start
-end
-t
- [0...1]- Returns:
-
interpolate
public static javax.vecmath.Point3d interpolate(javax.vecmath.Point3d start, javax.vecmath.Point3d end, double t) interpolate from start to end- Parameters:
start
-end
-t
- [0...1]- Returns:
-
slerp
public static javax.vecmath.Vector3d slerp(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double t) Spherical linear interpolation between two vectors.- Parameters:
a
- start vectorb
- end vectort
- [0...1]- Returns:
- interpolated vector
-
quatToEuler
public static double[] quatToEuler(javax.vecmath.Quat4d q) Convert quaternion 'q' to euler radian angles roll, pitch, yaw- Parameters:
q
-- Returns:
-
equals
public static boolean equals(javax.vecmath.Vector3d a, javax.vecmath.Vector3d b, double v) compare two vectors- Parameters:
a
- the first vectorb
- the second vectorv
- tolerance- Returns:
- true if the absolute difference on every axis is less than v
-