Xrb::Math Namespace Reference

Contains mathematical functions. More...


Functions

Float Radians (Float const angle)
 Converts degrees to radians.
Float Degrees (Float const radians)
 Converts radians to degrees.
Float CanonicalAngle (Float angle)
 Returns an equivalent angle in the range [-180, 180].
Float Sin (Float const angle)
 Returns the sine of the given angle.
Float Asin (Float const value)
 Returns the arcsine of the given value.
Float Cos (Float const angle)
 Returns the cosine of the given angle.
Float Acos (Float const value)
 Returns the arccosine of the given value.
Float Tan (Float const angle)
 Returns the tangent of the given angle.
Float Atan (Float const value)
 Returns the arctangent of the given angle.
Float Atan (FloatVector2 const &vector)
 Returns the angle that the given vector is making with the positive X axis.
Float Atan2 (Float const y, Float const x)
 Returns the arctangent of the ratio given by y/x.
FloatVector2 UnitVector (Float const angle)
 Returns the unit vector which makes the given angle with the positive X axis.
Float Sqrt (Float const x)
 Returns the positive square root of x.
Float Pow (Float const base, Float const exponent)
 Returns base raised to the exponent power.
Float PowInt (Float base, Uint32 exponent)
 Returns base raised to the integer exponent power.
Float RandomFloat (Float lower_bound, Float upper_bound)
 Returns a random Float within the range [lower_bound, upper_bound].
Uint16 RandomUint16 (Uint16 lower_bound=0, Uint16 upper_bound=65535)
 Returns a random Uint16 within the range [lower_bound, upper_bound].
Float RandomAngle ()
 Returns a random Float within 0.0f and 360.0f (an angle).
Float ExpBaseE (Float const exponent)
 Returns the constant "e" to the given exponent.
Float ExpBase10 (Float const exponent)
 Returns 10 raised to the given exponent.
Float LogBaseE (Float const x)
 Returns the natural logarithm of x.
Float LogBase10 (Float const x)
 Returns the base-10 logarithm of x.
Float Nan ()
 Returns the floating-point representation of not-a-number.
bool IsFinite (Float const x)
 Returns true iff the number is a normal finite number. i.e. not NaN or Inf.
Uint32 HighestBitIndex (Uint32 x)
 Returns the zero-based index of the highest bit in x (an unsigned, 32 bit value).
template<Uint32 fractional_bits, typename IntType >
IntType FixedPointRound (IntType x)
 Returns the closest integer (fixed-point) to the fixed-point value given by x .
Float FastSin (Float angle)
 Returns the sine of the given angle, with lower precision.
Float FastAsin (Float value)
 Returns the arcsine of the given value, with lower precision.
Float FastCos (Float angle)
 Returns the cosine of the given angle, with lower precision.
Float FastAcos (Float value)
 Returns the arccosine of the given value, with lower precision.
Float FastTan (Float angle)
 Returns the tangent of the given angle, with lower precision.
Float FastAtan (Float value)
 Returns the arctangent of the given value, with lower precision.
Float FastAtan (FloatVector2 const &vector)
 Returns the angle that the given vector is making with the positive X axis, with lower precision.
Float FastAtan2 (Float y, Float x)
 Returns the arctangent of the ratio given by y/x, with lower precision.
FloatVector2 FastUnitVector (Float angle)
 Returns the unit vector which makes the given angle with the positive X axis, with lower precision.
Float FastSqrt (Float x)
 Returns the positive square root of x, with lower precision.
Float FastPow (Float base, Float exponent)
 Returns base raised to the exponent power, with lower precision.
Float Floor (Float const x)
 Returns the floating-point representation of the nearest integer less than or equal to x.
Float Ceiling (Float const x)
 Returns the floating-point representation of the nearest integer greater than or equal to x.
Float Round (Float const x)
 Returns the floating-point representation of the integer nearest to x.


Detailed Description

Contains mathematical functions.

There are also a set of "fast" versions of some of the functions, which provide fast, but less-accurate results of the respective function.

All angles in XuqRijBuh are in degrees (unless otherwise specified), for representational convenience.


Function Documentation

Float Xrb::Math::CanonicalAngle ( Float  angle  ) 

Returns an equivalent angle in the range [-180, 180].

This should only be used on positional angles, not velocity angles.

Definition at line 18 of file xrb_math.cpp.

Float Xrb::Math::Atan2 ( Float const   y,
Float const   x 
) [inline]

Returns the arctangent of the ratio given by y/x.

This is used when x may be zero.

Definition at line 104 of file xrb_math.hpp.

References Degrees().

Referenced by FastAtan2().

Uint16 Xrb::Math::RandomUint16 ( Uint16  lower_bound = 0,
Uint16  upper_bound = 65535 
)

Returns a random Uint16 within the range [lower_bound, upper_bound].

The default parameter values are the lower and upper bounds of the Uint16 type 0 and 65535 respectively.

Definition at line 57 of file xrb_math.cpp.

Uint32 Xrb::Math::HighestBitIndex ( Uint32  x  ) 

Returns the zero-based index of the highest bit in x (an unsigned, 32 bit value).

If x is zero, then zero will be returned (even though there are no bits set in the integer representation of zero.

Definition at line 71 of file xrb_math.cpp.

template<Uint32 fractional_bits, typename IntType >
IntType Xrb::Math::FixedPointRound ( IntType  x  )  [inline]

Returns the closest integer (fixed-point) to the fixed-point value given by x .

Parameters:
x The fixed-point format value to round.

Definition at line 207 of file xrb_math.hpp.

Float Xrb::Math::FastAtan2 ( Float  y,
Float  x 
)

Returns the arctangent of the ratio given by y/x, with lower precision.

This is used when x may be zero.

Definition at line 146 of file xrb_math.cpp.

References Atan2().


Hosted by SourceForge.net Logo -- Generated on Fri Aug 21 21:46:39 2009 for XuqRijBuh by doxygen 1.5.8