de.cau.cs.kieler.core.util
Class KielerMath

java.lang.Object
  extended by de.cau.cs.kieler.core.util.KielerMath

public final class KielerMath
extends Object

Mathematics utility class for the KIELER projects.

Rating proposed yellow
(2009-12-11) msp

Nested Class Summary
static class KielerMath.Point
          Data class to store two coordinate values.
 
Method Summary
static int binomial(int n, int k)
          The binomial coefficient of integers n and k.
static KielerMath.Point[] calcBezierPoints(List<KielerMath.Point> controlPoints, int resultSize)
          Calculates a number of points on the Bezier curve defined by the given control points.
static long fact(int x)
          The factorial of an integer x.
static double maxd(double... values)
          Determines the maximum for an arbitrary number of doubles.
static float maxf(float... values)
          Determines the maximum for an arbitrary number of floats.
static int maxi(int... values)
          Determines the maximum for an arbitrary number of integers.
static double mind(double... values)
          Determines the minimum for an arbitrary number of doubles.
static float minf(float... values)
          Determines the minimum for an arbitrary number of floats.
static int mini(int... values)
          Determines the minimum for an arbitrary number of integers.
static double pow(double a, int b)
          The first argument raised to the power of the second argument.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

fact

public static long fact(int x)
The factorial of an integer x. If x is negative the result is 1.

Parameters:
x - an integer
Returns:
the factorial of x

binomial

public static int binomial(int n,
                           int k)
The binomial coefficient of integers n and k. If n is not positive or k is not between 0 and n the result is 1.

Parameters:
n - the upper integer
k - the lower integer
Returns:
n choose k

pow

public static double pow(double a,
                         int b)
The first argument raised to the power of the second argument.

Parameters:
a - the base
b - the exponent
Returns:
a to the power of b

calcBezierPoints

public static KielerMath.Point[] calcBezierPoints(List<KielerMath.Point> controlPoints,
                                                  int resultSize)
Calculates a number of points on the Bezier curve defined by the given control points. The degree of the curve is derived from the number of control points. The array of resulting curve points includes the target point, but does not include the source point of the curve.

Parameters:
controlPoints - list of control points
resultSize - number of returned curve points
Returns:
points on the curve defined by the given control points

maxi

public static int maxi(int... values)
Determines the maximum for an arbitrary number of integers.

Parameters:
values - integer values
Returns:
the maximum of the given values, or MIN_VALUE if no values are given

mini

public static int mini(int... values)
Determines the minimum for an arbitrary number of integers.

Parameters:
values - integer values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given

maxf

public static float maxf(float... values)
Determines the maximum for an arbitrary number of floats.

Parameters:
values - float values
Returns:
the maximum of the given values, or -MAX_VALUE if no values are given

minf

public static float minf(float... values)
Determines the minimum for an arbitrary number of floats.

Parameters:
values - float values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given

maxd

public static double maxd(double... values)
Determines the maximum for an arbitrary number of doubles.

Parameters:
values - double values
Returns:
the maximum of the given values, or -MAX_VALUE if no values are given

mind

public static double mind(double... values)
Determines the minimum for an arbitrary number of doubles.

Parameters:
values - double values
Returns:
the minimum of the given values, or MAX_VALUE if no values are given