Package cnuphys.magfield
Class FastMath
java.lang.Object
cnuphys.magfield.FastMath
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Which atan2, etc. algorithms to usestatic final class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
acos
(double x) static double
acos2Deg
(double x) Arc cosine returned in degreesstatic double
atan2
(double y, double x) Might use standard or fast atan2static double
atan2
(float y, float x) Might use standard or fast atan2static double
atan2Deg
(double y, double x) Might use standard or fast atan2static double
atan2Deg
(float y, float x) Might use standard or fast atan2static double
cos
(double x) Might use standard or fast cosstatic FastMath.MathLib
Get the math lib being usedstatic double
hypot
(double x, double y) static void
Set the math library to usestatic double
sin
(double x) Might use standard or fast sinstatic double
sqrt
(double x) Fast version of usual square rootstatic float
vectorLength
(float[] v) Vector length.
-
Constructor Details
-
FastMath
public FastMath()
-
-
Method Details
-
atan2
public static double atan2(float y, float x) Might use standard or fast atan2- Parameters:
y
-x
-- Returns:
- arctan(y/x) over 2Pi radians
-
atan2
public static double atan2(double y, double x) Might use standard or fast atan2- Parameters:
y
-x
-- Returns:
- arctan(y/x) over 2Pi radians
-
atan2Deg
public static double atan2Deg(float y, float x) Might use standard or fast atan2- Parameters:
y
-x
-- Returns:
- arctan(y/x) over 360 degrees
-
atan2Deg
public static double atan2Deg(double y, double x) Might use standard or fast atan2- Parameters:
y
-x
-- Returns:
- atan2(y, x)
-
hypot
public static double hypot(double x, double y) - Parameters:
x
-y
-- Returns:
-
acos
public static double acos(double x) - Parameters:
x
-- Returns:
-
acos2Deg
public static double acos2Deg(double x) Arc cosine returned in degrees- Parameters:
x
- the cosine value- Returns:
- acos in degrees
-
sqrt
public static double sqrt(double x) Fast version of usual square root- Parameters:
x
- the value- Returns:
- the square root of x
-
sin
public static double sin(double x) Might use standard or fast sin- Parameters:
x
- the angle in radians- Returns:
- the sine
-
cos
public static double cos(double x) Might use standard or fast cos- Parameters:
x
- the angle in radians- Returns:
- the cosine
-
getMathLib
Get the math lib being used- Returns:
- the math lib being used
-
vectorLength
public static float vectorLength(float[] v) Vector length.- Parameters:
v
- the v- Returns:
- the float
-
setMathLib
Set the math library to use- Parameters:
lib
- the math library enum
-