- java.lang.Object
-
- org.spongepowered.math.TrigMath
-
@CheckReturnValue public final class TrigMath extends Object
A class designed for fast trigonometry operations. Sine, cosine, tangent, cotangent secant and cosecant use a sine float table.
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEG_TO_RAD
static double
HALF_DEG_TO_RAD
static double
HALF_PI
static double
HALF_SQRT_OF_TWO
static double
PI
static double
QUARTER_PI
static double
RAD_TO_DEG
static double
SQRT_OF_TWO
static double
SQUARED_PI
static double
THREE_PI_HALVES
static double
TWO_PI
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
acos(double value)
Calculates the arc cosine of the value specified
Returns NaN if the input value is outside the cosine rangestatic double
acot(double value)
Calculates the arc cotangent of the value specified
Returns NaN if the input value is outside the cotangent rangestatic double
acsc(double value)
Calculates the arc cosecant of the value specified
Returns NaN if the input value is outside the cosecant rangestatic double
asec(double value)
Calculates the arc secant of the value specified
Returns NaN if the input value is outside the secant rangestatic double
asin(double value)
Calculates the arc sine of the value specified
Returns NaN if the input value is outside the sine rangestatic double
atan(double value)
Calculates the arc tangent of the value specifiedstatic double
atan2(double y, double x)
Computes the phase theta by computing an arc tangent of y/x
Gets the yaw rotation component in radians when looking into the direction specifiedstatic float
cos(double angle)
Cosine calculation using a table.static float
cot(double angle)
Cotangent calculations using a table.
cos(angle) / sin(angle)static float
csc(double angle)
Cosecant calculations using a table.
1 / sin(angle)static float
sec(double angle)
Secant calculations using a table:
1 / cos(angle)static float
sin(double angle)
Sine calculation using a table.static float
tan(double angle)
Tangent calculations using a table.
sin(angle) / cos(angle)
-
-
-
Field Detail
-
PI
public static final double PI
- See Also:
- Constant Field Values
-
SQUARED_PI
public static final double SQUARED_PI
- See Also:
- Constant Field Values
-
HALF_PI
public static final double HALF_PI
- See Also:
- Constant Field Values
-
QUARTER_PI
public static final double QUARTER_PI
- See Also:
- Constant Field Values
-
TWO_PI
public static final double TWO_PI
- See Also:
- Constant Field Values
-
THREE_PI_HALVES
public static final double THREE_PI_HALVES
- See Also:
- Constant Field Values
-
DEG_TO_RAD
public static final double DEG_TO_RAD
- See Also:
- Constant Field Values
-
HALF_DEG_TO_RAD
public static final double HALF_DEG_TO_RAD
- See Also:
- Constant Field Values
-
RAD_TO_DEG
public static final double RAD_TO_DEG
- See Also:
- Constant Field Values
-
SQRT_OF_TWO
public static final double SQRT_OF_TWO
-
HALF_SQRT_OF_TWO
public static final double HALF_SQRT_OF_TWO
-
-
Method Detail
-
sin
public static float sin(double angle)
Sine calculation using a table.No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- the angle in radians- Returns:
- the sine of the angle
-
cos
public static float cos(double angle)
Cosine calculation using a table.No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- the angle in radians- Returns:
- the cosine of the angle
-
tan
public static float tan(double angle)
Tangent calculations using a table.
sin(angle) / cos(angle)No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- in radians- Returns:
- the tangent of the angle
-
csc
public static float csc(double angle)
Cosecant calculations using a table.
1 / sin(angle)No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- the angle in radians- Returns:
- the cosecant of the angle
-
sec
public static float sec(double angle)
Secant calculations using a table:
1 / cos(angle)No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- the angle in radians- Returns:
- the secant of the angle
-
cot
public static float cot(double angle)
Cotangent calculations using a table.
cos(angle) / sin(angle)No interpolation is performed: Accuracy is up to the 6th decimal place.
- Parameters:
angle
- in radians- Returns:
- the cotangent of the angle
-
asin
public static double asin(double value)
Calculates the arc sine of the value specified
Returns NaN if the input value is outside the sine range- Parameters:
value
- of the sine- Returns:
- sine arc in radians
-
acos
public static double acos(double value)
Calculates the arc cosine of the value specified
Returns NaN if the input value is outside the cosine range- Parameters:
value
- of the cosine- Returns:
- cosine arc in radians
-
atan
public static double atan(double value)
Calculates the arc tangent of the value specified- Parameters:
value
- of the tangent- Returns:
- tangent arc in radians
-
atan2
public static double atan2(double y, double x)
Computes the phase theta by computing an arc tangent of y/x
Gets the yaw rotation component in radians when looking into the direction specified- Parameters:
y
- directionx
- direction- Returns:
- tangent arc in radians
-
acsc
public static double acsc(double value)
Calculates the arc cosecant of the value specified
Returns NaN if the input value is outside the cosecant range- Parameters:
value
- of the cosecant- Returns:
- cosecant arc in radians
-
asec
public static double asec(double value)
Calculates the arc secant of the value specified
Returns NaN if the input value is outside the secant range- Parameters:
value
- of the secant- Returns:
- secant arc in radians
-
acot
public static double acot(double value)
Calculates the arc cotangent of the value specified
Returns NaN if the input value is outside the cotangent range- Parameters:
value
- of the cotangent- Returns:
- cotangent arc in radians
-
-