subscript.math
Class MathUtil

java.lang.Object
  extended by subscript.math.MathUtil

public class MathUtil
extends java.lang.Object

Miscellaneous math utilities like mod2pi and fast exp functions.


Constructor Summary
MathUtil()
           
 
Method Summary
static double atan(double x)
          returns [-PI/2, PI/2] accurate within 0.269 degrees
static double atan2(double y, double x)
           
static void benchatan()
           
static void benchexp()
           
static double clamp(double v, double min, double max)
           
static int clamp(int v, int min, int max)
           
static boolean doubleEquals(double a, double b)
          Returns true if the two doubles are within a small epsilon of each other.
static double exp(double xin)
          Quickly compute e^x for all x.
static void inverse22(Matrix A)
           
static void inverse33(Matrix A)
           
static void main(java.lang.String[] args)
           
static double mod2pi(double vin)
          Ensure that v is [-PI, PI]
static double mod2pi(double ref, double v)
          Returns a value of v wrapped such that ref and v differ by no more +/-PI
static double square(double x)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtil

public MathUtil()
Method Detail

mod2pi

public static double mod2pi(double vin)
Ensure that v is [-PI, PI]


mod2pi

public static double mod2pi(double ref,
                            double v)
Returns a value of v wrapped such that ref and v differ by no more +/-PI


doubleEquals

public static boolean doubleEquals(double a,
                                   double b)
Returns true if the two doubles are within a small epsilon of each other.


clamp

public static int clamp(int v,
                        int min,
                        int max)

clamp

public static double clamp(double v,
                           double min,
                           double max)

square

public static final double square(double x)

exp

public static final double exp(double xin)
Quickly compute e^x for all x. Accuracy for x>0: x<0.5, absolute error < .0099 x>0.5, relative error 0.36% For x<0, we internally compute the reciprocal form; error is magnified. This approximation is also monotonic.


atan2

public static final double atan2(double y,
                                 double x)

atan

public static final double atan(double x)
returns [-PI/2, PI/2] accurate within 0.269 degrees


main

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

benchexp

public static void benchexp()

benchatan

public static void benchatan()

inverse22

public static void inverse22(Matrix A)

inverse33

public static void inverse33(Matrix A)