math
Class MathUtils

java.lang.Object
  extended by math.MathUtils

public class MathUtils
extends java.lang.Object


Field Summary
static double DEG_2_RAD
          Constant to convert degrees to radians.
static double LOG2
           
static double PI
           
static double PI_ON_180
           
static double PI_ON_2
           
static double PI_ON_4
           
static double RAD_2_DEG
          Constant to convert radians to degrees.
 
Constructor Summary
MathUtils()
           
 
Method Summary
static double acosd(double a)
          Returns the inverse cosine of a value, in the range of 0.0 through 180.0 degrees.
static double acosh(double a)
          Returns the inverse hyperbolic cosine of a value.
static double asind(double a)
          Returns the inverse sine of a value, in the range of -90.0 through 90.0 degrees.
static double asinh(double a)
          Returns the inverse hyperbolic sine of a value.
static int atan(int y, int x)
           
static double atan2d(double a, double b)
          Calculates the angle from the positive horizontal (x-)axis to a point (a,b), in the range of -180.0 through 180.0 degrees.
static double atand(double a)
          Returns the inverse tangent of a value, in the range of -90.0 through 90.0 degrees.
static double atanh(double a)
          Returns the inverse hyperbolic tangent of a value.
static short clip(short i)
           
static boolean closeEnough(double x, double y, double percentage)
           
static double cos(double alpha)
           
static double cosd(double a)
          Returns the cosine of an angle expressed in degrees.
static double cosh(double a)
          Returns the hyperbolic cosine of an angle.
static double factorial(int n)
           
static float factorial(short n)
           
static int fib(int n)
           
static int gcd(int a, int b)
           
static double getGauss(double x, double xc, double sigma)
           
static double[] getGauss(int n)
           
static double getLOG2()
           
static int getLogBase2(double d)
           
static double getLogBase2Double(double d)
           
static double getRandom(double min, double max)
           
static int getRandomNumber0_255()
           
static double getTrapezoidal(double x, double a, double b, double c, double d)
           
static boolean isOdd(int i)
           
static boolean isPowerOfTwo(double l)
           
static int isqrt(int x)
           
static short isqrt(short x)
           
static double log10(double a)
          Returns the logarithm to the base 10 of a number.
static double log2(double l)
           
static int log2(int l)
           
static double logBase2(int length)
           
static double logBase4(int length)
           
static void main(java.lang.String[] args)
           
static double max(int x, int y)
           
static boolean nextTo(int x0, int y0, int x1, int y1)
           
static boolean onLine(int x0, int y0, int x1, int y1, int x2, int y2)
           
static void print(double[] d)
           
static int roundToIntegralPowerOf2(int n)
           
static int sign(int x)
           
static double sin(double alpha)
           
static double sinc(double x)
          Returns the function sinc x, where sinc x is defined as sin x / x.
static double sind(double a)
          Returns the sine of an angle expressed in degrees.
static double sinh(double a)
          Returns the hyperbolic sine of an angle.
static float sqrt(double f)
           
static float sqrt(float f)
           
static double tand(double a)
          Returns the tangent of an angle expressed in degrees.
static double tanh(double a)
          Returns the hyperbolic tangent of an angle.
static void testCloseEnough()
           
static void testGauss()
           
static void testLongIsqrt()
           
static void writeOutRandomNumbersToAFile()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG2

public static final double LOG2

PI_ON_180

public static final double PI_ON_180
See Also:
Constant Field Values

PI

public static final double PI
See Also:
Constant Field Values

PI_ON_2

public static final double PI_ON_2
See Also:
Constant Field Values

PI_ON_4

public static final double PI_ON_4
See Also:
Constant Field Values

DEG_2_RAD

public static final double DEG_2_RAD
Constant to convert degrees to radians.

See Also:
Constant Field Values

RAD_2_DEG

public static final double RAD_2_DEG
Constant to convert radians to degrees.

See Also:
Constant Field Values
Constructor Detail

MathUtils

public MathUtils()
Method Detail

writeOutRandomNumbersToAFile

public static void writeOutRandomNumbersToAFile()

isOdd

public static boolean isOdd(int i)

getLogBase2

public static int getLogBase2(double d)
Parameters:
d - input argument to the log2 function
Returns:
base 2 log.

getLogBase2Double

public static double getLogBase2Double(double d)

getGauss

public static double getGauss(double x,
                              double xc,
                              double sigma)

getGauss

public static double[] getGauss(int n)

testGauss

public static void testGauss()

print

public static final void print(double[] d)

testLongIsqrt

public static void testLongIsqrt()

isqrt

public static short isqrt(short x)

isqrt

public static int isqrt(int x)

roundToIntegralPowerOf2

public static int roundToIntegralPowerOf2(int n)

getTrapezoidal

public static double getTrapezoidal(double x,
                                    double a,
                                    double b,
                                    double c,
                                    double d)

gcd

public static int gcd(int a,
                      int b)

log2

public static int log2(int l)

getLOG2

public static double getLOG2()

log2

public static double log2(double l)

isPowerOfTwo

public static boolean isPowerOfTwo(double l)

sign

public static int sign(int x)

cos

public static double cos(double alpha)

sin

public static double sin(double alpha)

atan

public static int atan(int y,
                       int x)

nextTo

public static boolean nextTo(int x0,
                             int y0,
                             int x1,
                             int y1)

onLine

public static boolean onLine(int x0,
                             int y0,
                             int x1,
                             int y1,
                             int x2,
                             int y2)

max

public static double max(int x,
                         int y)

sqrt

public static float sqrt(float f)

sqrt

public static float sqrt(double f)

logBase2

public static double logBase2(int length)

logBase4

public static double logBase4(int length)

fib

public static int fib(int n)

acosd

public static double acosd(double a)
Returns the inverse cosine of a value, in the range of 0.0 through 180.0 degrees. Valid input range is -1.0 <= a <= 1.0.

Parameters:
a - input value in the range -1.0 <= a <= 1.0.
Returns:
the angle in degrees.

acosh

public static double acosh(double a)
Returns the inverse hyperbolic cosine of a value. Valid input range is a >= 1.0.

Parameters:
a - input value in the range a >= 1.0.
Returns:
the inverse hyperbolic cosine

asind

public static double asind(double a)
Returns the inverse sine of a value, in the range of -90.0 through 90.0 degrees. Valid input range is -1.0 <= a <= 1.0.

Parameters:
a - input value in the range -1.0 <= a <= 1.0.
Returns:
the angle in degrees.

asinh

public static double asinh(double a)
Returns the inverse hyperbolic sine of a value.

Parameters:
a - input value
Returns:
the inverse hyperbolic sine

atand

public static double atand(double a)
Returns the inverse tangent of a value, in the range of -90.0 through 90.0 degrees. Valid input range is -Inf < a < Inf.

Parameters:
a - input value
Returns:
the angle in degrees.

atanh

public static double atanh(double a)
Returns the inverse hyperbolic tangent of a value.

Parameters:
a - input value
Returns:
the inverse hyperbolic tangent

atan2d

public static double atan2d(double a,
                            double b)
Calculates the angle from the positive horizontal (x-)axis to a point (a,b), in the range of -180.0 through 180.0 degrees.

Parameters:
a - x-input value
a - y-input value
Returns:
the angle in degrees.

cosd

public static double cosd(double a)
Returns the cosine of an angle expressed in degrees.

Parameters:
a - an angle, in degrees.
Returns:
the cosine of the argument.

cosh

public static double cosh(double a)
Returns the hyperbolic cosine of an angle.

Parameters:
a - an angle, in radians.
Returns:
the hyperbolic cosine of the argument.

log10

public static double log10(double a)
Returns the logarithm to the base 10 of a number.

Parameters:
a - a double value
Returns:
the logarithm to the base 10 of the argument.

sinc

public static double sinc(double x)
Returns the function sinc x, where sinc x is defined as sin x / x.

Parameters:
x - input value.
Returns:
the sinc of the argument.

sind

public static double sind(double a)
Returns the sine of an angle expressed in degrees.

Parameters:
a - an angle, in degrees.
Returns:
the sine of the argument.

sinh

public static double sinh(double a)
Returns the hyperbolic sine of an angle.

Parameters:
a - an angle, in radians.
Returns:
the hyperbolic sine of the argument.

tand

public static double tand(double a)
Returns the tangent of an angle expressed in degrees.

Parameters:
a - an angle, in degrees.
Returns:
the tangent of the argument.

tanh

public static double tanh(double a)
Returns the hyperbolic tangent of an angle.

Parameters:
a - an angle, in radians.
Returns:
the hyperbolic tangent of the argument.

getRandomNumber0_255

public static int getRandomNumber0_255()
Returns:
a random integer from 0..255

getRandom

public static double getRandom(double min,
                               double max)
Parameters:
min - range
max - range
Returns:
a random number from min to max

clip

public static short clip(short i)

closeEnough

public static boolean closeEnough(double x,
                                  double y,
                                  double percentage)

testCloseEnough

public static void testCloseEnough()

factorial

public static double factorial(int n)

factorial

public static float factorial(short n)

main

public static void main(java.lang.String[] args)