Class Trigonometry
public final class Trigonometry
Provides fast, approximate trigonometric functions backed by precomputed look-up tables. Useful when many calls are made per frame and the slight
approximation error introduced by table look-ups is acceptable.
-
Method Summary
Modifier and TypeMethodDescriptionstatic floatatan2(float y, float x) Fast approximation of [double)][Math#atan2(double,] in radians.static floatatan2Deg(float y, float x) Fast approximation of [double)][Math#atan2(double,] in degrees.static floatatan2DegStrict(float y, float x) Strict (non-approximated) [double)][Math#atan2(double,] in degrees.static final floatcos(float rad) Fast approximation ofMath.cos(double).static final floatcosDeg(float deg) Fast approximation ofMath.cos(double)accepting degrees.static final floatsin(float rad) Fast approximation ofMath.sin(double).static final floatsinDeg(float deg) Fast approximation ofMath.sin(double)accepting degrees.
-
Method Details
-
atan2
public static float atan2(float y, float x) Fast approximation of [double)][Math#atan2(double,] in radians.- Parameters:
y- the y componentx- the x component- Returns:
- the angle, in radians
-
atan2Deg
public static float atan2Deg(float y, float x) Fast approximation of [double)][Math#atan2(double,] in degrees.- Parameters:
y- the y componentx- the x component- Returns:
- the angle, in degrees
-
atan2DegStrict
public static float atan2DegStrict(float y, float x) Strict (non-approximated) [double)][Math#atan2(double,] in degrees.- Parameters:
y- the y componentx- the x component- Returns:
- the angle, in degrees
-
cos
public static final float cos(float rad) Fast approximation ofMath.cos(double).- Parameters:
rad- the angle, in radians- Returns:
- the cosine
-
cosDeg
public static final float cosDeg(float deg) Fast approximation ofMath.cos(double)accepting degrees.- Parameters:
deg- the angle, in degrees- Returns:
- the cosine
-
sin
public static final float sin(float rad) Fast approximation ofMath.sin(double).- Parameters:
rad- the angle, in radians- Returns:
- the sine
-
sinDeg
public static final float sinDeg(float deg) Fast approximation ofMath.sin(double)accepting degrees.- Parameters:
deg- the angle, in degrees- Returns:
- the sine
-