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  point
class  vector
class  float2
class  line
class  noise
class  polar
class  rectangle
class  sphere
class  transform44
class  float4
class  matrix44
class  plane
class  quaternion

Functions

__forceinline scalar n_log2 (scalar f)
__forceinline int n_iclamp (int val, int minVal, int maxVal)
__forceinline bool n_fequal (scalar f0, scalar f1, scalar tol)
__forceinline bool n_fless (scalar f0, scalar f1, scalar tol)
__forceinline bool n_fgreater (scalar f0, scalar f1, scalar tol)
__forceinline scalar n_smooth (scalar newVal, scalar curVal, scalar maxChange)
__forceinline scalar n_clamp (scalar val, scalar lower, scalar upper)
__forceinline scalar n_saturate (scalar val)
__forceinline scalar n_rand ()
__forceinline scalar n_rand (scalar min, scalar max)
__forceinline int n_fchop (scalar f)
__forceinline int n_frnd (scalar f)
__forceinline float n_lerp (scalar x, scalar y, scalar l)
__forceinline scalar n_modangle (scalar a)
__forceinline scalar n_angulardistance (scalar from, scalar to)

Function Documentation

__forceinline scalar Math::n_log2 ( scalar  f  ) 

log2() function.

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

Integer clamping.

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

A fuzzy floating point equality check

__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_smooth ( scalar  newVal,
scalar  curVal,
scalar  maxChange 
)

Smooth a new value towards an old value using a change value.

__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 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 int Math::n_frnd ( scalar  f  ) 

Round float to integer.

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

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

__forceinline scalar Math::n_modangle ( scalar  a  ) 

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

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

Get angular distance.