PWToolBox::Math Namespace Reference

The PWToolBox::Math namespace contains some commonly used math functions that are not provided by the <cmath> header. More...


Functions

template<typename T>
T const Lerp (T const &a, T const &b, float const s)
 Interpolates between a and b based on s.
template<typename T>
T const Clamp (T const &value, T const &low, T const &high)
 Clamps a value to the range [low,high].
template<typename T>
T const Saturate (T const &value)
 A specialized case of the Clamp function with a range [0,1].


Detailed Description

The PWToolBox::Math namespace contains some commonly used math functions that are not provided by the <cmath> header.

The goal of the Math namespace is not to replace standard math functions, but to compliment them. Thus to use standard math functions you still have to use <cmath>.


Function Documentation

template<typename T>
T const PWToolBox::Math::Clamp ( T const &  value,
T const &  low,
T const &  high 
) [inline]

Clamps a value to the range [low,high].

Parameters:
value The value to clamp
low The lowest value in the range.
high The highest value in the range
Returns:
A value clamped between [low, high]

template<typename T>
T const PWToolBox::Math::Lerp ( T const &  a,
T const &  b,
float const   s 
) [inline]

Interpolates between a and b based on s.

If s is not in the range [0,1] a linear extrapolation is performed instead.

Parameters:
a The first value
b The second value
s A value that interpolates between a and b
Returns:
When s is 0, a is returned. When s is 1, b is returned. When s is between 0 and 1, a linear interpolation between a and b is returned.

template<typename T>
T const PWToolBox::Math::Saturate ( T const &  value  )  [inline]

A specialized case of the Clamp function with a range [0,1].

Parameters:
value The value to saturate


Generated on Sun Jul 13 14:18:30 2008 for PWToolBox by  doxygen 1.5.1