Package org.lazywizard.lazylib
Class FastTrig
Object
FastTrig
Math utility class that trades accuracy for speed, often returning several times faster than
Math's
equivalent functions.- Since:
- 1.0
- Author:
- Various (see javadoc of individual methods for attributions)
-
Method Summary
Modifier and TypeMethodDescriptionstatic doubleatan(double z) Returns the arc tangent of a value.static doubleatan2(double y, double x) Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta).static doublecos(double radians) Get the cosine of an angle.static doublesin(double radians) Get the sine of an angle.
-
Method Details
-
sin
public static double sin(double radians) Get the sine of an angle.Originally written by JeffK, and taken from the Slick2D game library.
- Parameters:
radians- The angle, in radians.- Returns:
- The sine of
radians. - Since:
- 1.0
-
cos
public static double cos(double radians) Get the cosine of an angle.Originally written by JeffK, and taken from the Slick2D game library.
- Parameters:
radians- The angle, in radians.- Returns:
- The cosine of
radians. - Since:
- 1.0
-
atan
public static double atan(double z) Returns the arc tangent of a value. Accurate to within 0.005 radians, or ~0.29 degrees.Originally written by Nic Taylor, and taken from this page.
- Parameters:
z- The value to calculate the arc tangent of.- Returns:
- The arc tangent of
z, in radians. - Since:
- 2.3
-
atan2
public static double atan2(double y, double x) Returns the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). Accurate to within 0.005 radians, or ~0.29 degrees.Originally written by Nic Taylor, further modified by imuli, and taken from this page.
- Parameters:
y- The ordinate coordinate.x- The abscissa coordinate.- Returns:
- The theta component of the point (r, theta) in polar coordinates that corresponds to the point (x, y) in Cartesian coordinates.
- Since:
- 2.3
-