java.lang.Object
org.spongepowered.math.TrigMath
A class designed for fast trigonometry operations. Sine, cosine, tangent, cotangent secant and cosecant use a sine float table.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
static final double
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
PI
public static final double PI- See Also:
-
SQUARED_PI
public static final double SQUARED_PI- See Also:
-
HALF_PI
public static final double HALF_PI- See Also:
-
QUARTER_PI
public static final double QUARTER_PI- See Also:
-
TWO_PI
public static final double TWO_PI- See Also:
-
THREE_PI_HALVES
public static final double THREE_PI_HALVES- See Also:
-
DEG_TO_RAD
public static final double DEG_TO_RAD- See Also:
-
HALF_DEG_TO_RAD
public static final double HALF_DEG_TO_RAD- See Also:
-
RAD_TO_DEG
public static final double RAD_TO_DEG- See Also:
-
SQRT_OF_TWO
public static final double SQRT_OF_TWO -
HALF_SQRT_OF_TWO
public static final double HALF_SQRT_OF_TWO
-
-
Method Details
-
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
-