public abstract class MathG extends Object
This class may use approximations with various levels of error. The "G" in the name stands for "Graphics", because it was originally conceived as a tool to speed up graphics. When I iterate over every pixel in an image to perform some operation: I don't really need the precision that the Math class offers.
Many thanks to Oleg E. for some insights regarding machine error and design.
See MathGDemo.java for a set of tests comparing the speed/accuracy of java.lang.Math and com.bric.math.MathG.
| Constructor and Description |
|---|
MathG()
|
| Modifier and Type | Method and Description |
|---|---|
static double |
acos(double v)
Returns an approximate value of the acos(v) that should be within plus-or-minus .00004 of the value returned by Math.acos().
|
static double |
ceilDouble(double d)
Finds the closest integer that is greater than or equal to the argument as a double.
|
static int |
ceilInt(double d)
Finds the closest integer that is greater than or equal to the argument as an int.
|
static double |
cos00004(double v)
Returns an approximate value of the cos(v) that should be within plus-or-minus .00004 of the value returned by Math.cos().
|
static double |
cos01(double v)
Returns an approximate value of the cos(v) that should be within plus-or-minus .0108 of the value returned by Math.cos().
|
static double |
floorDouble(double d)
Finds the closest integer that is less than or equal to the argument as a double.
|
static int |
floorInt(double d)
Finds the closest integer that is less than or equal to the argument as an int.
|
static double |
roundDouble(double d)
Rounds a double to the nearest integer value.
|
static int |
roundInt(double d)
Rounds a double to the nearest integer value.
|
static double |
sin00004(double v)
Returns an approximate value of the sin(v) that should be within plus-or-minus .00004 of the value returned by Math.sin().
|
static double |
sin01(double v)
Returns an approximate value of the sin(v) that should be within plus-or-minus .0108 of the value returned by Math.sin().
|
public static final double floorDouble(double d)
d - the value to calculate the floor of.
public static final int floorInt(double d)
d - the value to calculate the floor of.
public static final int roundInt(double d)
d - the value to round.
public static final double roundDouble(double d)
d - the value to round.
public static final int ceilInt(double d)
d - the value to calculate the ceil of.
public static final double ceilDouble(double d)
d - the value to calculate the ceil of.
public static final double sin01(double v)
If the argument is greater in magnitude than 1e10, then this delegates to Math.sin().
v -
public static final double cos01(double v)
If the argument is greater in magnitude than 1e10, then this delegates to Math.cos().
v -
public static final double sin00004(double v)
If the argument is greater in magnitude than 1e10, then this delegates to Math.sin().
v -
public static final double acos(double v)
v -
public static final double cos00004(double v)
If the argument is greater in magnitude than 1e10, then this delegates to Math.cos().
v -