Package com.sk89q.worldedit.math
Class MathUtils
java.lang.Object
com.sk89q.worldedit.math.MathUtils
Various math utility methods.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Safe minimum, such that 1 / SAFE_MIN does not overflow. -
Method Summary
Modifier and TypeMethodDescriptionstatic double
dCos
(double degrees) Returns the cosine of an angle given in degrees.static int
divisorMod
(int a, int n) Modulus, divisor-style.static double
dSin
(double degrees) Returns the sine of an angle given in degrees.static double
roundHalfUp
(double value) Returns the rounded double of the given value, rounding to the nearest integer value away from zero on ties.
-
Field Details
-
SAFE_MIN
public static final double SAFE_MINSafe minimum, such that 1 / SAFE_MIN does not overflow.In IEEE 754 arithmetic, this is also the smallest normalized number 2-1022. The value of this constant is from Apache Commons Math 2.2.
- See Also:
-
-
Method Details
-
divisorMod
public static int divisorMod(int a, int n) Modulus, divisor-style.- Parameters:
a
- an
- n- Returns:
- the modulus
-
dCos
public static double dCos(double degrees) Returns the cosine of an angle given in degrees. This is better than justMath.cos(Math.toRadians(degrees))
because it provides a more accurate result for angles divisible by 90 degrees.- Parameters:
degrees
- the angle- Returns:
- the cosine of the given angle
-
dSin
public static double dSin(double degrees) Returns the sine of an angle given in degrees. This is better than justMath.sin(Math.toRadians(degrees))
because it provides a more accurate result for angles divisible by 90 degrees.- Parameters:
degrees
- the angle- Returns:
- the sine of the given angle
-
roundHalfUp
public static double roundHalfUp(double value) Returns the rounded double of the given value, rounding to the nearest integer value away from zero on ties.This behavior is the same as
RoundingMode.HALF_UP
.- Parameters:
value
- the value- Returns:
- the rounded value
-