Axiom::MathLib::MathUtil Class Reference

This is a class which exposes static methods for various common math functions. Currently, the methods simply wrap the methods of the System.Math class (with the exception of a few added extras). This is in case the implementation needs to be swapped out with a faster C++ implementation, if deemed that the System.Math methods are not up to far speed wise. More...

List of all members.

Static Public Member Functions

static float DegreesToRadians (float degrees)
 Converts degrees to radians.
static float RadiansToDegrees (float radians)
 Converts radians to degrees.
static float Sin (float angle)
 Returns the sine of the angle.
static Vector3 CalculateBasicFaceNormal (Vector3 v1, Vector3 v2, Vector3 v3)
 Calculate a face normal, no w-information.
static Vector3 CalculateTangentSpaceVector (Vector3 position1, Vector3 position2, Vector3 position3, float u1, float v1, float u2, float v2, float u3, float v3)
 Calculates the tangent space vector for a given set of positions / texture coords.
static float Cos (float angle)
 Returns the cosine of the angle.
static float ACos (float angle)
 Returns the arc cosine of the angle.
static float ASin (float angle)
 Returns the arc sine of the angle.
static float InvSqrt (float number)
 Inverse square root.
static float Sqrt (float number)
 Returns the square root of a number.
static float Abs (float number)
 Returns the absolute value of the supplied number.
static bool FloatEqual (float a, float b, float tolerance)
 Compares float values for equality, taking into consideration that floating point values should never be directly compared using ==. 2 floats could be conceptually equal, but vary by a .000001 which would fail in a direct comparison. To circumvent that, a tolerance value is used to see if the difference between the 2 floats is less than the desired amount of accuracy.
static float Tan (float angle)
 Returns the tangent of the angle.
static float Max (float value1, float value2)
 Used to quickly determine the greater value between two values.
static float Min (float value1, float value2)
 Used to quickly determine the lesser value between two values.
static float RangeRandom (float min, float max)
 Returns a random value between the specified min and max values.
static float UnitRandom ()
static float SymmetricRandom ()
static bool PointInTri2D (float px, float py, float ax, float ay, float bx, float by, float cx, float cy)
 Checks wether a given point is inside a triangle, in a 2-dimensional (Cartesian) space.


Detailed Description

This is a class which exposes static methods for various common math functions. Currently, the methods simply wrap the methods of the System.Math class (with the exception of a few added extras). This is in case the implementation needs to be swapped out with a faster C++ implementation, if deemed that the System.Math methods are not up to far speed wise.

TODO: Add overloads for all methods for all instrinsic data types (i.e. float, short, etc).


Member Function Documentation

static float Axiom::MathLib::MathUtil::Abs float  number  )  [inline, static]
 

Returns the absolute value of the supplied number.

Parameters:
number 
Returns:

static float Axiom::MathLib::MathUtil::ACos float  angle  )  [inline, static]
 

Returns the arc cosine of the angle.

Parameters:
angle 
Returns:

static float Axiom::MathLib::MathUtil::ASin float  angle  )  [inline, static]
 

Returns the arc sine of the angle.

Parameters:
angle 
Returns:

static Vector3 Axiom::MathLib::MathUtil::CalculateBasicFaceNormal Vector3  v1,
Vector3  v2,
Vector3  v3
[inline, static]
 

Calculate a face normal, no w-information.

Parameters:
v1 
v2 
v3 
Returns:

static Vector3 Axiom::MathLib::MathUtil::CalculateTangentSpaceVector Vector3  position1,
Vector3  position2,
Vector3  position3,
float  u1,
float  v1,
float  u2,
float  v2,
float  u3,
float  v3
[inline, static]
 

Calculates the tangent space vector for a given set of positions / texture coords.

Adapted from bump mapping tutorials at: http://www.paulsprojects.net/tutorials/simplebump/simplebump.html author : paul.baker@univ.ox.ac.uk

Parameters:
position1 
position2 
position3 
u1 
v1 
u2 
v2 
u3 
v3 
Returns:

static float Axiom::MathLib::MathUtil::Cos float  angle  )  [inline, static]
 

Returns the cosine of the angle.

Parameters:
angle 
Returns:

static float Axiom::MathLib::MathUtil::DegreesToRadians float  degrees  )  [inline, static]
 

Converts degrees to radians.

Parameters:
degrees 
Returns:

static bool Axiom::MathLib::MathUtil::FloatEqual float  a,
float  b,
float  tolerance
[inline, static]
 

Compares float values for equality, taking into consideration that floating point values should never be directly compared using ==. 2 floats could be conceptually equal, but vary by a .000001 which would fail in a direct comparison. To circumvent that, a tolerance value is used to see if the difference between the 2 floats is less than the desired amount of accuracy.

Parameters:
a 
b 
tolerance 
Returns:

static float Axiom::MathLib::MathUtil::InvSqrt float  number  )  [inline, static]
 

Inverse square root.

Parameters:
number 
Returns:

static float Axiom::MathLib::MathUtil::Max float  value1,
float  value2
[inline, static]
 

Used to quickly determine the greater value between two values.

Parameters:
value1 
value2 
Returns:

static float Axiom::MathLib::MathUtil::Min float  value1,
float  value2
[inline, static]
 

Used to quickly determine the lesser value between two values.

Parameters:
value1 
value2 
Returns:

static bool Axiom::MathLib::MathUtil::PointInTri2D float  px,
float  py,
float  ax,
float  ay,
float  bx,
float  by,
float  cx,
float  cy
[inline, static]
 

Checks wether a given point is inside a triangle, in a 2-dimensional (Cartesian) space.

The vertices of the triangle must be given in either trigonometrical (anticlockwise) or inverse trigonometrical (clockwise) order.

Parameters:
px The X-coordinate of the point.
py The Y-coordinate of the point.
ax The X-coordinate of the triangle's first vertex.
ay The Y-coordinate of the triangle's first vertex.
bx The X-coordinate of the triangle's second vertex.
by The Y-coordinate of the triangle's second vertex.
cx The X-coordinate of the triangle's third vertex.
cy The Y-coordinate of the triangle's third vertex.
Returns:
  • true - the point resides in the triangle.
  • false - the point is outside the triangle

static float Axiom::MathLib::MathUtil::RadiansToDegrees float  radians  )  [inline, static]
 

Converts radians to degrees.

Parameters:
radians 
Returns:

static float Axiom::MathLib::MathUtil::RangeRandom float  min,
float  max
[inline, static]
 

Returns a random value between the specified min and max values.

Parameters:
min Minimum value.
max Maximum value.
Returns:
A random value in the range [min,max].

static float Axiom::MathLib::MathUtil::Sin float  angle  )  [inline, static]
 

Returns the sine of the angle.

Parameters:
angle 
Returns:

static float Axiom::MathLib::MathUtil::Sqrt float  number  )  [inline, static]
 

Returns the square root of a number.

This is one of the more expensive math operations. Avoid when possible.

Parameters:
number 
Returns:

static float Axiom::MathLib::MathUtil::SymmetricRandom  )  [inline, static]
 

Returns:

static float Axiom::MathLib::MathUtil::Tan float  angle  )  [inline, static]
 

Returns the tangent of the angle.

Parameters:
angle 
Returns:

static float Axiom::MathLib::MathUtil::UnitRandom  )  [inline, static]
 

Returns:


The documentation for this class was generated from the following file:
Generated on Mon Jan 23 19:31:15 2006 for FlowVis by  doxygen 1.4.5