com.bbn.openmap
Class MoreMath

java.lang.Object
  extended by com.bbn.openmap.MoreMath

public class MoreMath
extends java.lang.Object

MoreMath provides functions that are not part of the standard Math class.

 
  Functions:
       asinh(float x) - hyperbolic arcsine
       sinh(float x) - hyperbolic sine
 
  Need to Implement:
  Function                Definition                              
  Hyperbolic cosine       (eˆx+eˆ-x)/2                            
  Hyperbolic tangent      (eˆx-eˆ-x)/(eˆx+eˆ-x)                   
  Hyperbolic arc cosine   2 log  (sqrt((x+1)/2) + sqrt((x-1)/2))  
  Hyperbolic arc tangent  (log  (1+x) - log (1-x))/2
  
 


Field Summary
static double EQUIVALENT_TOLERANCE
           
static float HALF_PI
          Math.PI/2
static double HALF_PI_D
          Math.PI/2
static float TWO_PI
          2*Math.PI
static double TWO_PI_D
          2*Math.PI
 
Method Summary
static boolean approximately_equal(double a, double b)
          Checks if a ~= b.
static boolean approximately_equal(double a, double b, double epsilon)
          Checks if a ~= b.
static boolean approximately_equal(float a, float b, float epsilon)
          Checks if a ~= b.
static double asinh(double x)
          Hyperbolic arcsin.
static float asinh(float x)
          Hyperbolic arcsin.
static int BuildInteger(byte[] bytevec, boolean MSBFirst)
          Build int out of bytes.
static int BuildInteger(byte[] bytevec, int offset, boolean MSBFirst)
          Build int out of bytes.
static int BuildIntegerBE(byte[] bytevec)
          Build int out of bytes (in big endian order).
static int BuildIntegerBE(byte[] bytevec, int offset)
          Build int out of bytes (in big endian order).
static int BuildIntegerLE(byte[] bytevec)
          Build int out of bytes (in little endian order).
static int BuildIntegerLE(byte[] bytevec, int offset)
          Build int out of bytes (in little endian order).
static long BuildLong(byte[] bytevec, boolean MSBFirst)
          Build long out of bytes.
static long BuildLong(byte[] bytevec, int offset, boolean MSBFirst)
          Build long out of bytes.
static long BuildLongBE(byte[] bytevec)
          Build long out of bytes (in big endian order).
static long BuildLongBE(byte[] bytevec, int offset)
          Build long out of bytes (in big endian order).
static long BuildLongLE(byte[] bytevec)
          Build long out of bytes (in little endian order).
static long BuildLongLE(byte[] bytevec, int offset)
          Build long out of bytes (in little endian order).
static short BuildShort(byte[] bytevec, boolean MSBFirst)
          Build short out of bytes.
static short BuildShort(byte[] bytevec, int offset, boolean MSBFirst)
          Build short out of bytes.
static short BuildShortBE(byte[] bytevec, boolean MSBFirst)
          Build short out of bytes (in big endian order).
static short BuildShortBE(byte[] bytevec, int offset)
          Build short out of bytes (in big endian order).
static short BuildShortLE(byte[] bytevec, boolean MSBFirst)
          Build short out of bytes (in little endian order).
static short BuildShortLE(byte[] bytevec, int offset)
          Build short out of bytes (in little endian order).
static boolean even(int x)
          Check if number is even.
static boolean even(long x)
          Check if number is even.
static boolean even(short x)
          Check if number is even.
static double justLessThan(double val, double lessThan, double howMuchLess)
          Return value just less than provided value, in positive and negative terms.
static double latJLT90(double val)
          lat just less than 90 degrees.
static boolean odd(int x)
          Check if number is odd.
static boolean odd(long x)
          Check if number is odd.
static boolean odd(short x)
          Check if number is odd.
static int sign(double x)
          Return sign of number.
static int sign(float x)
          Return sign of number.
static int sign(int x)
          Return sign of number.
static int sign(long x)
          Return sign of number.
static int sign(short x)
          Return sign of number.
static int signedToInt(byte b)
          Converts a byte in the range of -128 to 127 to an int in the range 0 - 255.
static int signedToInt(short w)
          Converts a short in the range of -32768 to 32767 to an int in the range 0 - 65535.
static long signedToLong(int x)
          Convert an int in the range of -2147483648 to 2147483647 to a long in the range 0 to 4294967295.
static int wordToByte(int w)
          Converts an int in the range of 0 - 65535 to an int in the range of 0 - 255.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TWO_PI

public static final transient float TWO_PI
2*Math.PI

See Also:
Constant Field Values

TWO_PI_D

public static final transient double TWO_PI_D
2*Math.PI

See Also:
Constant Field Values

HALF_PI

public static final transient float HALF_PI
Math.PI/2

See Also:
Constant Field Values

HALF_PI_D

public static final transient double HALF_PI_D
Math.PI/2

See Also:
Constant Field Values

EQUIVALENT_TOLERANCE

public static final double EQUIVALENT_TOLERANCE
See Also:
Constant Field Values
Method Detail

approximately_equal

public static final boolean approximately_equal(double a,
                                                double b,
                                                double epsilon)
Checks if a ~= b. Use this to test equality of floating point numbers.

Parameters:
a - double
b - double
epsilon - the allowable error
Returns:
boolean

approximately_equal

public static final boolean approximately_equal(double a,
                                                double b)
Checks if a ~= b. Use this to test equality of floating point numbers against EQUIVALENT_TOLERANCE.

Parameters:
a - double
b - double
Returns:
boolean

approximately_equal

public static final boolean approximately_equal(float a,
                                                float b,
                                                float epsilon)
Checks if a ~= b. Use this to test equality of floating point numbers.

Parameters:
a - float
b - float
epsilon - the allowable error
Returns:
boolean

asinh

public static final float asinh(float x)
Hyperbolic arcsin.

Hyperbolic arc sine: log (x+sqrt(1+x^2))

Parameters:
x - float
Returns:
float asinh(x)

asinh

public static final double asinh(double x)
Hyperbolic arcsin.

Hyperbolic arc sine: log (x+sqrt(1+x^2))

Parameters:
x - double
Returns:
double asinh(x)

sign

public static final int sign(short x)
Return sign of number.

Parameters:
x - short
Returns:
int sign -1, 1

sign

public static final int sign(int x)
Return sign of number.

Parameters:
x - int
Returns:
int sign -1, 1

sign

public static final int sign(long x)
Return sign of number.

Parameters:
x - long
Returns:
int sign -1, 1

sign

public static final int sign(float x)
Return sign of number.

Parameters:
x - float
Returns:
int sign -1, 1

sign

public static final int sign(double x)
Return sign of number.

Parameters:
x - double
Returns:
int sign -1, 1

odd

public static final boolean odd(short x)
Check if number is odd.

Parameters:
x - short
Returns:
boolean

odd

public static final boolean odd(int x)
Check if number is odd.

Parameters:
x - int
Returns:
boolean

odd

public static final boolean odd(long x)
Check if number is odd.

Parameters:
x - long
Returns:
boolean

even

public static final boolean even(short x)
Check if number is even.

Parameters:
x - short
Returns:
boolean

even

public static final boolean even(int x)
Check if number is even.

Parameters:
x - int
Returns:
boolean

even

public static final boolean even(long x)
Check if number is even.

Parameters:
x - long
Returns:
boolean

signedToInt

public static final int signedToInt(byte b)
Converts a byte in the range of -128 to 127 to an int in the range 0 - 255.

Parameters:
b - (-128 <= b <= 127)
Returns:
int (0 <= b <= 255)

signedToInt

public static final int signedToInt(short w)
Converts a short in the range of -32768 to 32767 to an int in the range 0 - 65535.

Parameters:
w - (-32768 <= b <= 32767)
Returns:
int (0 <= b <= 65535)

signedToLong

public static final long signedToLong(int x)
Convert an int in the range of -2147483648 to 2147483647 to a long in the range 0 to 4294967295.

Parameters:
x - (-2147483648 <= x <= 2147483647)
Returns:
long (0 <= x <= 4294967295)

wordToByte

public static final int wordToByte(int w)
Converts an int in the range of 0 - 65535 to an int in the range of 0 - 255.

Parameters:
w - int (0 <= w <= 65535)
Returns:
int (0 <= w <= 255)

BuildShortBE

public static final short BuildShortBE(byte[] bytevec,
                                       int offset)
Build short out of bytes (in big endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
short

BuildShortLE

public static final short BuildShortLE(byte[] bytevec,
                                       int offset)
Build short out of bytes (in little endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
short

BuildShort

public static final short BuildShort(byte[] bytevec,
                                     int offset,
                                     boolean MSBFirst)
Build short out of bytes.

Parameters:
bytevec - bytes
offset - byte offset
MSBFirst - BE or LE?
Returns:
short

BuildShortBE

public static final short BuildShortBE(byte[] bytevec,
                                       boolean MSBFirst)
Build short out of bytes (in big endian order).

Parameters:
bytevec - bytes
MSBFirst - BE or LE?
Returns:
short

BuildShortLE

public static final short BuildShortLE(byte[] bytevec,
                                       boolean MSBFirst)
Build short out of bytes (in little endian order).

Parameters:
bytevec - bytes
MSBFirst - BE or LE?
Returns:
short

BuildShort

public static final short BuildShort(byte[] bytevec,
                                     boolean MSBFirst)
Build short out of bytes.

Parameters:
bytevec - bytes
MSBFirst - BE or LE?
Returns:
short

BuildIntegerBE

public static final int BuildIntegerBE(byte[] bytevec,
                                       int offset)
Build int out of bytes (in big endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
int

BuildIntegerLE

public static final int BuildIntegerLE(byte[] bytevec,
                                       int offset)
Build int out of bytes (in little endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
int

BuildInteger

public static final int BuildInteger(byte[] bytevec,
                                     int offset,
                                     boolean MSBFirst)
Build int out of bytes.

Parameters:
bytevec - bytes
offset - byte offset
MSBFirst - BE or LE?
Returns:
int

BuildIntegerBE

public static final int BuildIntegerBE(byte[] bytevec)
Build int out of bytes (in big endian order).

Parameters:
bytevec - bytes
Returns:
int

BuildIntegerLE

public static final int BuildIntegerLE(byte[] bytevec)
Build int out of bytes (in little endian order).

Parameters:
bytevec - bytes
Returns:
int

BuildInteger

public static final int BuildInteger(byte[] bytevec,
                                     boolean MSBFirst)
Build int out of bytes.

Parameters:
bytevec - bytes
MSBFirst - BE or LE?
Returns:
int

BuildLongBE

public static final long BuildLongBE(byte[] bytevec,
                                     int offset)
Build long out of bytes (in big endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
long

BuildLongLE

public static final long BuildLongLE(byte[] bytevec,
                                     int offset)
Build long out of bytes (in little endian order).

Parameters:
bytevec - bytes
offset - byte offset
Returns:
long

BuildLong

public static final long BuildLong(byte[] bytevec,
                                   int offset,
                                   boolean MSBFirst)
Build long out of bytes.

Parameters:
bytevec - bytes
offset - byte offset
MSBFirst - BE or LE?
Returns:
long

BuildLongBE

public static final long BuildLongBE(byte[] bytevec)
Build long out of bytes (in big endian order).

Parameters:
bytevec - bytes
Returns:
long

BuildLongLE

public static final long BuildLongLE(byte[] bytevec)
Build long out of bytes (in little endian order).

Parameters:
bytevec - bytes
Returns:
long

BuildLong

public static final long BuildLong(byte[] bytevec,
                                   boolean MSBFirst)
Build long out of bytes.

Parameters:
bytevec - bytes
MSBFirst - BE or LE?
Returns:
long

latJLT90

public static double latJLT90(double val)
lat just less than 90 degrees.

Parameters:
val - lat value to test
Returns:
value just less than...

justLessThan

public static double justLessThan(double val,
                                  double lessThan,
                                  double howMuchLess)
Return value just less than provided value, in positive and negative terms.

Parameters:
val - value to test
lessThan - abs value to test against
howMuchLess - how much to move val to zero based on comparison to less than
Returns:
val, or adjusted val


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details