The Nebula Device 3: Math Namespace Reference

The Nebula Device 3

Math Namespace Reference


Detailed Description

Nebula3's Math subsystem offers a standalone library of C++ math classes. Nothing unusual about them ;)

FIXME: make math code less object oriented and more like HLSL for better performance and portability to Xbox360.

Data Structures

class  bbox
class  ClipStatus
class  Extrapolator
class  float2
class  frustum
class  line
class  noise
class  polar
class  rectangle
class  sphere
class  transform44
class  float4
class  matrix44
class  plane
class  point
class  quaternion
class  vector

Functions

__forceinline bool n_fequal (scalar f0, scalar f1, scalar tol)
__forceinline int n_iclamp (int val, int minVal, int maxVal)
__forceinline bool n_fless (scalar f0, scalar f1, scalar tol)
__forceinline bool n_fgreater (scalar f0, scalar f1, scalar tol)
__forceinline scalar n_clamp (scalar val, scalar lower, scalar upper)
__forceinline scalar n_saturate (scalar val)
__forceinline double n_saturate (double val)
__forceinline scalar n_lerp (scalar x, scalar y, scalar l)
__forceinline double n_lerp (double x, double y, double l)
__forceinline scalar n_angulardistance (scalar from, scalar to)
__forceinline bool n_isdenormal (scalar s)
__forceinline float n_undenormalize (scalar s)
__forceinline bool n_nearequal (scalar a, scalar b, scalar epsilon)
__forceinline scalar n_rand ()
__forceinline scalar n_rand (scalar min, scalar max)
__forceinline int n_fchop (scalar f)
__forceinline scalar n_modangle (scalar a)
__forceinline scalar n_log2 (scalar f)
__forceinline int n_frnd (scalar f)
__forceinline scalar n_log (scalar x)

Function Documentation

__forceinline bool Math::n_fequal ( scalar  f0,
scalar  f1,
scalar  tol 
)

A fuzzy floating point equality check

__forceinline int Math::n_iclamp ( int  val,
int  minVal,
int  maxVal 
)

Integer clamping.

__forceinline bool Math::n_fless ( scalar  f0,
scalar  f1,
scalar  tol 
)

A fuzzy floating point less-then check.

__forceinline bool Math::n_fgreater ( scalar  f0,
scalar  f1,
scalar  tol 
)

A fuzzy floating point greater-then check.

__forceinline scalar Math::n_clamp ( scalar  val,
scalar  lower,
scalar  upper 
)

Clamp a value against lower und upper boundary.

__forceinline scalar Math::n_saturate ( scalar  val  ) 

Saturate a value (clamps between 0.0f and 1.0f)

__forceinline double Math::n_saturate ( double  val  ) 

Saturate a value (clamps between 0.0f and 1.0f)

__forceinline scalar Math::n_lerp ( scalar  x,
scalar  y,
scalar  l 
)

Linearly interpolate between 2 values: ret = x + l * (y - x)

__forceinline double Math::n_lerp ( double  x,
double  y,
double  l 
)

Linearly interpolate between 2 values: ret = x + l * (y - x)

__forceinline scalar Math::n_angulardistance ( scalar  from,
scalar  to 
)

Get angular distance.

__forceinline bool Math::n_isdenormal ( scalar  s  ) 

Returns true if the input scalar is denormalized (DEN)

__forceinline float Math::n_undenormalize ( scalar  s  ) 

Returns 0 if scalar is denormal.

__forceinline bool Math::n_nearequal ( scalar  a,
scalar  b,
scalar  epsilon 
)

test of nearly equal given a tolerance (epsilon)

__forceinline scalar Math::n_rand (  ) 

Return a pseudo random number between 0 and 1.

__forceinline scalar Math::n_rand ( scalar  min,
scalar  max 
)

Return a pseudo random number between min and max.

__forceinline int Math::n_fchop ( scalar  f  ) 

Chop float to int.

__forceinline scalar Math::n_modangle ( scalar  a  ) 

Normalize an angular value into the range rad(0) to rad(360).

__forceinline scalar Math::n_log2 ( scalar  f  ) 

log2() function.

__forceinline int Math::n_frnd ( scalar  f  ) 

Round float to integer.

__forceinline scalar Math::n_log ( scalar  x  ) 

get logarithm of x