Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

base::Math Class Reference

class of useful math utilities More...

Inheritance diagram for base::Math:

Inheritance graph
[legend]
Collaboration diagram for base::Math:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual String className () const
virtual bool isSameKindAs (const Object &) const

Static Public Member Functions

Real degToRad (Real d)
 convert degrees to radians

Real radToDeg (Real r)
 convert radians to degrees

Real sqr (Real n)
 square (i.e. n*n)

Real sqrt (Real n)
 squate root (i.e. n^.5)

Real cube (Real n)
 cube (i.e. n*n*n)

Real abs (Real s)
 absolute value (i.e. |s|)

Real sign (Real n)
 sign (i.e. -1 if n<0, 0 if n=0, 1 if n>0)

Real pow (Real x, Real y)
 x raised to the power y

Real random ()
 random number [0..1]

bool isNAN (Real n)
 true if n is Not-A-Number

Real sin (Real a)
Real cos (Real a)
Real tan (Real a)
Real asin (Real a)
Real acos (Real a)
Real atan (Real a)
Real atan2 (Real a, Real b)
bool equals (const Real r1, const Real r2, Real eps=consts::epsilon)
 equals within eps (i.e. true if |r1-r2| < eps)

Real zeroIfNeighbour (Real n, Real neighbourhoodRadius=consts::epsilon)
 0 if in neighbourhood of 0 (i.e. 0 if |n| < neighbourhoodRadius, n otherwise)

template<typename T> T minimum (const T &t1, const T &t2)
 minimum (i.e. t1 if t1<t2, t2 otherwise)

template<typename T> T minimum (const T &t1, const T &t2, const T &t3)
 minimum (i.e. minimum(t1,t2) if minimum(t1,t2) < minimum(t2,t3), minimum(t2,t3) otherwise)

template<typename T> T maximum (const T &t1, const T &t2)
 maximum (i.e. t1 if t1>t2, t2 otherwise)

template<typename T> T maximum (const T &t1, const T &t2, const T &t3)
 maximum (i.e. maximum(t1,t2) if maximum(t1,t2) > maximum(t2,t3), maximum(t2,t3) otherwise)

template<typename T> void bound (T &v, const T &lower, const T &upper)
 bound a value to the specified range

Real normalizeAngle (Real angle)
 normalize angles (in radians) to the range (-pi..pi]

Real normalizeAngle2PI (Real angle)
 normalize angles (in radians) to the range [0..2pi)

Real angleDifference (Real angle1, Real angle2)
void decomposeLUP (const Matrix &A, Matrix &L, Matrix &U, Vector &Pi, Real epsilon=consts::epsilon2)
 Find LUP decomposition of Matrix.

Vector solveLUP (const Matrix &L, const Matrix &U, const Vector &Pi, const Vector &b)
 Solve for Ax = b, given LUP decomposition of A as L, U and Pi, and given b, returns x.

Matrix inverse (const Matrix &A, Real epsilon=consts::epsilon2)
 inverse of A (using LUP decomposition)

Matrix nullSpace (const Matrix &A, Int &nullSpaceRank, Real &k2)
 null-space of Matrix A (using Singular Value Decomposition - SVD)

Matrix pseudoInverse (const Matrix &A)
 the Moore-Penrose pseudo-inverse of A (using SVD)


Protected Member Functions

 Math ()
 Math (const Math &)
virtual ~Math ()

Detailed Description

class of useful math utilities

NB: see also functions in Consts

Todo:
consider using a Singelton policy template class for this (and perhaps also Application)

Definition at line 45 of file Math.


Constructor & Destructor Documentation

base::Math::Math  )  [inline, protected]
 

Definition at line 162 of file Math.

base::Math::Math const Math  )  [inline, protected]
 

Definition at line 163 of file Math.

virtual base::Math::~Math  )  [inline, protected, virtual]
 

Definition at line 164 of file Math.


Member Function Documentation

Real base::Math::abs Real  s  )  [inline, static]
 

absolute value (i.e. |s|)

Definition at line 62 of file Math.

References base::Real.

Real base::Math::acos Real  a  )  [inline, static]
 

Definition at line 80 of file Math.

References base::Real.

Real base::Math::angleDifference Real  angle1,
Real  angle2
[static]
 

difference between two angles (e.g. -160deg - 170deg = 30deg) Return is normalized (-pi..pi]

Real base::Math::asin Real  a  )  [inline, static]
 

Definition at line 79 of file Math.

References base::Real.

Real base::Math::atan Real  a  )  [inline, static]
 

Definition at line 81 of file Math.

References base::Real.

Real base::Math::atan2 Real  a,
Real  b
[inline, static]
 

Definition at line 82 of file Math.

References base::Real.

template<typename T>
void base::Math::bound T &  v,
const T &  lower,
const T &  upper
[inline, static]
 

bound a value to the specified range

Definition at line 105 of file Math.

virtual String base::Math::className  )  const [inline, virtual]
 

return the name of the object's class type. Must be defined by derived classes.

Implements base::Object.

Definition at line 48 of file Math.

References base::String.

Real base::Math::cos Real  a  )  [inline, static]
 

Definition at line 77 of file Math.

References base::Real.

Real base::Math::cube Real  n  )  [inline, static]
 

cube (i.e. n*n*n)

Definition at line 60 of file Math.

References base::Real.

void base::Math::decomposeLUP const Matrix A,
Matrix L,
Matrix U,
Vector Pi,
Real  epsilon = consts::epsilon2
[static]
 

Find LUP decomposition of Matrix.

P is represented by the vector Pi, where the element values represent the column of P containing a 1. i.e. Pi[i]=j => P[i][j]=1

Real base::Math::degToRad Real  d  )  [inline, static]
 

convert degrees to radians

Definition at line 51 of file Math.

References base::Real.

bool base::Math::equals const Real  r1,
const Real  r2,
Real  eps = consts::epsilon
[inline, static]
 

equals within eps (i.e. true if |r1-r2| < eps)

Definition at line 86 of file Math.

References base::Real.

Matrix base::Math::inverse const Matrix A,
Real  epsilon = consts::epsilon2
[static]
 

inverse of A (using LUP decomposition)

bool base::Math::isNAN Real  n  )  [inline, static]
 

true if n is Not-A-Number

Definition at line 72 of file Math.

References base::Real.

virtual bool base::Object::isSameKindAs const Object  )  const [inline, virtual, inherited]
 

Definition at line 47 of file Object.

template<typename T>
T base::Math::maximum const T &  t1,
const T &  t2,
const T &  t3
[inline, static]
 

maximum (i.e. maximum(t1,t2) if maximum(t1,t2) > maximum(t2,t3), maximum(t2,t3) otherwise)

Definition at line 101 of file Math.

template<typename T>
T base::Math::maximum const T &  t1,
const T &  t2
[inline, static]
 

maximum (i.e. t1 if t1>t2, t2 otherwise)

Definition at line 99 of file Math.

template<typename T>
T base::Math::minimum const T &  t1,
const T &  t2,
const T &  t3
[inline, static]
 

minimum (i.e. minimum(t1,t2) if minimum(t1,t2) < minimum(t2,t3), minimum(t2,t3) otherwise)

Definition at line 97 of file Math.

template<typename T>
T base::Math::minimum const T &  t1,
const T &  t2
[inline, static]
 

minimum (i.e. t1 if t1<t2, t2 otherwise)

Definition at line 95 of file Math.

Real base::Math::normalizeAngle Real  angle  )  [inline, static]
 

normalize angles (in radians) to the range (-pi..pi]

Definition at line 110 of file Math.

References base::Real.

Real base::Math::normalizeAngle2PI Real  angle  )  [inline, static]
 

normalize angles (in radians) to the range [0..2pi)

Definition at line 118 of file Math.

References base::Real.

Matrix base::Math::nullSpace const Matrix A,
Int nullSpaceRank,
Real k2
[static]
 

null-space of Matrix A (using Singular Value Decomposition - SVD)

Parameters:
A input matrix for which the null-space is calculated (MxN, where M<=N)
nullSpaceRank output rank of the null space returned
k2 output matrix condition number
Returns:
null-space vectors

Real base::Math::pow Real  x,
Real  y
[inline, static]
 

x raised to the power y

Definition at line 66 of file Math.

References base::Real.

Matrix base::Math::pseudoInverse const Matrix A  )  [static]
 

the Moore-Penrose pseudo-inverse of A (using SVD)

Real base::Math::radToDeg Real  r  )  [inline, static]
 

convert radians to degrees

Definition at line 53 of file Math.

References base::Real.

Real base::Math::random  )  [inline, static]
 

random number [0..1]

Definition at line 68 of file Math.

References base::Real.

Real base::Math::sign Real  n  )  [inline, static]
 

sign (i.e. -1 if n<0, 0 if n=0, 1 if n>0)

Definition at line 64 of file Math.

References base::Real.

Real base::Math::sin Real  a  )  [inline, static]
 

Definition at line 76 of file Math.

References base::Real.

Vector base::Math::solveLUP const Matrix L,
const Matrix U,
const Vector Pi,
const Vector b
[static]
 

Solve for Ax = b, given LUP decomposition of A as L, U and Pi, and given b, returns x.

Real base::Math::sqr Real  n  )  [inline, static]
 

square (i.e. n*n)

Definition at line 56 of file Math.

References base::Real.

Real base::Math::sqrt Real  n  )  [inline, static]
 

squate root (i.e. n^.5)

Definition at line 58 of file Math.

References Assert, and base::Real.

Real base::Math::tan Real  a  )  [inline, static]
 

Definition at line 78 of file Math.

References base::Real.

Real base::Math::zeroIfNeighbour Real  n,
Real  neighbourhoodRadius = consts::epsilon
[inline, static]
 

0 if in neighbourhood of 0 (i.e. 0 if |n| < neighbourhoodRadius, n otherwise)

Definition at line 90 of file Math.

References base::Real.


The documentation for this class was generated from the following file:
Generated on Thu Jul 29 16:38:42 2004 for OpenSim by doxygen 1.3.6