- 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 doubleDEG_TO_RADstatic doubleHALF_DEG_TO_RADstatic doubleHALF_PIstatic doubleHALF_SQRT_OF_TWOstatic doublePIstatic doubleQUARTER_PIstatic doubleRAD_TO_DEGstatic doubleSQRT_OF_TWOstatic doubleSQUARED_PIstatic doubleTHREE_PI_HALVESstatic doubleTWO_PI
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleacos(double value)Calculates the arc cosine of the value specified
Returns NaN if the input value is outside the cosine rangestatic doubleacot(double value)Calculates the arc cotangent of the value specified
Returns NaN if the input value is outside the cotangent rangestatic doubleacsc(double value)Calculates the arc cosecant of the value specified
Returns NaN if the input value is outside the cosecant rangestatic doubleasec(double value)Calculates the arc secant of the value specified
Returns NaN if the input value is outside the secant rangestatic doubleasin(double value)Calculates the arc sine of the value specified
Returns NaN if the input value is outside the sine rangestatic doubleatan(double value)Calculates the arc tangent of the value specifiedstatic doubleatan2(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 floatcos(double angle)Cosine calculation using a table.static floatcot(double angle)Cotangent calculations using a table.
cos(angle) / sin(angle)static floatcsc(double angle)Cosecant calculations using a table.
1 / sin(angle)static floatsec(double angle)Secant calculations using a table:
1 / cos(angle)static floatsin(double angle)Sine calculation using a table.static floattan(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
-
-