Namespaces | Defines | Functions | Variables

_src_math_funcs.hh File Reference

Math functions for computer graphics. More...

#include "math/funcs_debug.hh"

Go to the source code of this file.

Namespaces

namespace  math
 

math functions


namespace  math::defs

Defines

#define IfNan(N)   (UX(!std::isfinite(N)))

Functions

template<typename FP >
bool math::FP_EQ (FP a, FP b)
template<typename FP >
bool math::FP_LE (FP a, FP b)
template<typename FP >
bool math::FP_GE (FP a, FP b)
template<typename T1 , typename T2 >
bool math::IfSameSign (const T1 a, const T2 b)
template<typename FP >
FP math::SquareRoot (FP f)
template<typename T >
math::Square (T x)
template<typename T >
math::Average (T x, T y)
template<typename T >
math::Range (T val, T lo, T hi)
template<typename T >
math::IfInRange (T a0, T a1, T b0, T b1)
INLINE fp math::FractionInRange (fp n, fp low, fp high)
INLINE fp math::Remap (fp value, fp rangeOld, fp rangeNew)
INLINE fp math::Truncate (fp val, fp interval)
template<typename T >
math::ModuloAbs (const T n, const T limit)

Variables

const fpx math::defs::FP_DELTA_TOLERANCE = 0.001
 used for comparing fp values

Detailed Description

Math functions for computer graphics.

LastChangedDate:
2010-10-23 18:22:39 -0400 (Sat, 23 Oct 2010)
Author:
Jim E. Brooks http://www.palomino3d.org
Remarks:
- A few functions are named specially to avoid ambiguity with standard functions.
  • To speed or improve FP execution:
    • use multiplication instead of division
    • power of 2 operations involve no loss of accuracy
    • math::PI is preferred over M_PI etc from math.h. math.h has confusing defines such as M_2_PI which means 2/PI (not 2*PI).
  • NaN are caused by division and some standard C math functions.
  • All modern FPUs are based on IEEE 754. A single-precision 32-bit FP is limited to 24 bits (8 decimal digits) of precision.
  • C++ <cmath> is better than C <math.h> because C++ functions are overloaded. REMINDERS: - Consider using MATH_EXCEPTION() instead of ASSERT().

Define Documentation

#define IfNan (   N  )     (UX(!std::isfinite(N)))

IfNan() returns true if a Not-A-Number or Infinity. C99 isfinite() is true if neither NaN nor infinity. Technically, divide-by-zero results in Infinity, not NaN, but IfNan() is used to check divide errors. A NaN never equals any number -- not even itself. !(n==n) is unreliable because smart compilers will optimize as always false (gcc will).

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Palomino Flight Simulator documents generated by doxygen 1.7.1 on Tue May 15 2012 22:40:10