math Namespace Reference

Math related functions and classes. More...


Classes

class  matrix4
 A 4x4 matrix. More...
class  quaternion
 A quaternion. More...
class  vector3
 A 3-dimensional vector. More...

Functions

double rand01 (void)
 Returns a random number between 0.0 and 1.0.
double to_degrees (double x)
 Converts radians to degrees.
double to_radians (double x)
 Converts degrees to radians.
bool equals (double x, double y)
 Precision aware equals.
template<class T >
void swap (T &x, T &y)
 Swaps x and y.
double sign (double x)
 Finds the sign of x.
bool same_sign (double x, double y)
 Checks if x and y share the same sign.
bool negative (double x)
 Check if x is negative.
bool positive (double x)
 Check if x is positive.
float angle_normalize_360 (float angle)
 Returns a normalized angle [0,360).
float angle_normalize_180 (float angle)
 Returns a normalized angle (-180,180].
float angle_subtract (float a, float b)
 Returns the difference of 2 angles. Result is in the range (-180,180].
template<class T >
clamp (T value, T min, T max)
 Clamp the value to the specified range.
math::vector3 operator* (const math::vector3 &v, const math::matrix4 &m)
std::ostream & operator<< (std::ostream &o, const math::matrix4 &m)
std::ostream & operator<< (std::ostream &o, const math::quaternion &vec)
math::vector3 cross (const math::vector3 &lhs, const math::vector3 &rhs)
void add (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
void subtract (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
void multiply (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
void divide (math::vector3 &dest, const math::vector3 &lhs, const math::vector3 &rhs)
void multiply (math::vector3 &dest, const math::vector3 &lhs, real_t rhs)
void multiply (math::vector3 &dest, real_t rhs, const math::vector3 &lhs)
real_t dot (const math::vector3 &lhs, const math::vector3 &rhs)
math::vector3 operator* (real_t lhs, const math::vector3 &rhs)
std::ostream & operator<< (std::ostream &o, const math::vector3 &vec)


Detailed Description

Math related functions and classes.


Function Documentation

bool math::equals ( double  x,
double  y 
) [inline]

Precision aware equals.

Returns true if x is equal to y. To account for precision errors, true is returned if x differs from y by less than MATH_EPSILON.

Definition at line 81 of file mathematics.h.

References MATH_EPSILON.

Referenced by math::quaternion::from_angle_axis(), math::quaternion::get_angle_axis(), math::matrix4::get_inverted_rotation(), math::vector3::normalize(), math::vector3::operator!=(), math::vector3::operator==(), and math::quaternion::slerp().

bool math::negative ( double  x  )  [inline]

Check if x is negative.

Returns:
true if x is less than 0.0.

Definition at line 137 of file mathematics.h.

bool math::positive ( double  x  )  [inline]

Check if x is positive.

Returns:
true if x is greater than or equal to 0.0.

Definition at line 151 of file mathematics.h.

bool math::same_sign ( double  x,
double  y 
) [inline]

Checks if x and y share the same sign.

Returns:
true if x and y share the same sign.

Definition at line 123 of file mathematics.h.

double math::sign ( double  x  )  [inline]

Finds the sign of x.

Returns:
-1.0 if x is less than 0.0, 1.0 otherwise.

Definition at line 109 of file mathematics.h.

template<class T >
void math::swap ( T &  x,
T &  y 
) [inline]

Swaps x and y.

Templated swap function. Assumes the following:

  • type has copy constructor
  • the assignment operator is defined for type
Note:
std::swap() works just as well. This function is included here to be backwards compatible with old code.

Definition at line 97 of file mathematics.h.

Referenced by math::matrix4::transpose().

double math::to_degrees ( double  x  )  [inline]

Converts radians to degrees.

Parameters:
x double in radians
Returns:
x converted to degrees.

Definition at line 59 of file mathematics.h.

double math::to_radians ( double  x  )  [inline]

Converts degrees to radians.

Parameters:
x double in degrees
Returns:
x converted to radians.

Definition at line 70 of file mathematics.h.


Generated on Sat Feb 21 16:38:10 2009 for Flock of Birds Library by  doxygen 1.5.7.1