jabble
Class MathUtils

java.lang.Object
  extended by jabble.MathUtils

public class MathUtils
extends java.lang.Object

A toolkit class containing a set of mathematical functions typically used for initial conditions (gaussian, pulse, step, ...).


Method Summary
static double gaussian(double x, double centerX, double width)
          1D gaussian, centered on centerX and with the specified width.
static double gaussian(double x, double y, double centerX, double centerY, double width)
          2D gaussian, centered on centerX/Y and with the specified width.
static double gaussian(double x, double y, double z, double centerX, double centerY, double centerZ, double width)
          3D gaussian, centered on centerX/Y/Z and with the specified width.
static double module(double a, double b)
          Returns the modulus from the two components.
static double module2(double a, double b)
          Returns the modulus square of a complex number given the real and imaginary part.
static double modulus(double... components)
          Calculates the modulus given the components of a vector.
static double phase(double a, double b)
          Returns the phase of a complex number given the real and imaginary part.
static double phaseDiff(double theta1, double theta2)
          Returns the difference of the two angles, taking into account periodicity.
static double reverseStep(double x, double stepX)
          Reverse step function, returns 1.0 before stepX and 1.0 afterwards.
static double squarePulse(double x, double lowerX, double upperX)
          1D pulse, returns 1.0 within the range and 0.0 outside.
static double squarePulse(double x, double y, double lowerX, double upperX, double lowerY, double upperY)
          2D pulse, returns 1.0 within the range and 0.0 outside.
static double squarePulse(double x, double y, double z, double lowerX, double upperX, double lowerY, double upperY, double lowerZ, double upperZ)
          3D pulse, returns 1.0 within the range and 0.0 outside.
static double step(double x, double stepX)
          Step funtion, returns 0.0 before stepX and 1.0 afterwards.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

phase

public static double phase(double a,
                           double b)
Returns the phase of a complex number given the real and imaginary part.

Parameters:
a - real part of a complex number
b - imaginary part of a complex number
Returns:
the phase of a complex number

module2

public static double module2(double a,
                             double b)
Returns the modulus square of a complex number given the real and imaginary part.

Parameters:
a - real part of a complex number
b - imaginary part of a complex number
Returns:
the modulus square

module

public static double module(double a,
                            double b)
Returns the modulus from the two components.

Parameters:
a - real part of a complex number
b - imaginary part of a complex number
Returns:
the modulus

modulus

public static double modulus(double... components)
Calculates the modulus given the components of a vector.

Parameters:
components - the components
Returns:
the modulus

phaseDiff

public static double phaseDiff(double theta1,
                               double theta2)
Returns the difference of the two angles, taking into account periodicity.

Parameters:
theta1 - an angle
theta2 - anothe angle
Returns:
the difference between the two

gaussian

public static double gaussian(double x,
                              double y,
                              double z,
                              double centerX,
                              double centerY,
                              double centerZ,
                              double width)
3D gaussian, centered on centerX/Y/Z and with the specified width.

Parameters:
x - coordinate x
y - coordinate y
z - coordinate z
centerX - center of the gaussian on x
centerY - center of the gaussian on y
centerZ - center of the gaussian on z
width - width of the gaussian in all directions
Returns:
the value of the function at the given coordinates

gaussian

public static double gaussian(double x,
                              double y,
                              double centerX,
                              double centerY,
                              double width)
2D gaussian, centered on centerX/Y and with the specified width.

Parameters:
x - coordinate x
y - coordinate y
centerX - center of the gaussian on x
centerY - center of the gaussian on y
width - width of the gaussian in all directions
Returns:
the value of the function at the given coordinates

gaussian

public static double gaussian(double x,
                              double centerX,
                              double width)
1D gaussian, centered on centerX and with the specified width.

Parameters:
x - coordinate x
centerX - center of the gaussian on x
width - width of the gaussian in all directions
Returns:
the value of the function at the given coordinates

squarePulse

public static double squarePulse(double x,
                                 double lowerX,
                                 double upperX)
1D pulse, returns 1.0 within the range and 0.0 outside.

Parameters:
x - coordinate x
lowerX - lower boundary for the pulse
upperX - upper boundary for the pulse
Returns:
the value of the function at the given coordinates

squarePulse

public static double squarePulse(double x,
                                 double y,
                                 double lowerX,
                                 double upperX,
                                 double lowerY,
                                 double upperY)
2D pulse, returns 1.0 within the range and 0.0 outside.

Parameters:
x - coordinate x
y - coordinate y
lowerX - lower boundary for the pulse on x
upperX - upper boundary for the pulse on x
lowerY - lower boundary for the pulse on y
upperY - upper boundary for the pulse on y
Returns:
the value of the function at the given coordinates

squarePulse

public static double squarePulse(double x,
                                 double y,
                                 double z,
                                 double lowerX,
                                 double upperX,
                                 double lowerY,
                                 double upperY,
                                 double lowerZ,
                                 double upperZ)
3D pulse, returns 1.0 within the range and 0.0 outside.

Parameters:
x - coordinate x
y - coordinate y
z - coordinate z
lowerX - lower boundary for the pulse on x
upperX - upper boundary for the pulse on x
lowerY - lower boundary for the pulse on y
upperY - upper boundary for the pulse on y
lowerZ - lower boundary for the pulse on z
upperZ - upper boundary for the pulse on z
Returns:
the value of the function at the given coordinates

step

public static double step(double x,
                          double stepX)
Step funtion, returns 0.0 before stepX and 1.0 afterwards.

Parameters:
x - coordinate x
stepX - value at which the function changes
Returns:
the value of the function at the given coordinates

reverseStep

public static double reverseStep(double x,
                                 double stepX)
Reverse step function, returns 1.0 before stepX and 1.0 afterwards.

Parameters:
x - coordinate x
stepX - value at which the function changes
Returns:
the value of the function at the given coordinates