flMath.c File Reference

#include "flGlobal.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

Go to the source code of this file.

Functions

void mathInit ()
 This is called by flInitialize(), it initializes the maths system, by seeding the random number generator and if trigcaching is used then it creates the cache.
void mathRandSeed (u32 inSeed)
 This function reseeds the random number generator.
float mathRandf (float inSize)
 This function returns a pseudo random number between 0 and inSize.
float mathRandFractf ()
 This function returns a pseudo random number between 0 and 1.
unsigned int mathRandi (unsigned int inSize)
 This function returns a pseudo random integer between 0 and inSize - 1, for example mathRandi(10) would return a number from 0 to 9.
s64 mathRandl (s64 inSize)
 This function returns a pseudo random integer between 0 and inSize - 1, this function is the same as mathRandi() however it uses double accuracy signed integers.
float mathFixDegRange (float inDeg)
 Fixes numbers to be within the standard range for degrees which is 0 to 360.
float mathFixRadRange (float inRad)
 Fixes numbers to be within the standard range for radians which is 0 to 2pi.
float mathDegToRad (float inDeg)
 Converts a degree value to radians (e.g 180 would return pi).
float mathRadToDeg (float inRad)
 Converts a radian value to degrees (e.g pi/2 would return 90).
float mathSinf (float inAngle)
 This is basically a wrapper for sinf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.
float mathCosf (float inAngle)
 This is basically a wrapper for cosf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.
float mathACosf (float inAngle)
 This is basically a wrapper for acosf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.
float mathATanf (float inAngle)
 This is basically a wrapper for atanf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.
float mathExpnf (float inValue)
 This is basically a wrapper for expf from libmath, it returns the natural exponent of a number.
float mathLnf (float inValue)
 This is basically a wrapper for logf from libmath, it returns the natural logarithm of a number.
float mathPythag2f (float inX, float inY)
 This returns the the square root of inX^2 + inY^2.
float mathPythag3f (float inX, float inY, float inZ)
 This returns the the square root of inX^2 + inY^2 + inZ^2.
float mathDotProdN (float *inValue0, float *inValue1, u8 inCount)
 This returns the dot product of inCount sets of values.
float mathQuatLength (quat4f inQuat)
quat4fmathQuatNormalize (quat4f *inQuat)
quat4f mathQuatNormal (quat4f inQuat)
quat4fmathQuatNegate (quat4f *inQuat)
quat4f mathQuatNegation (quat4f inQuat)
quat4f mathQuatMult (quat4f inQuat0, quat4f inQuat1)
vect3f mathVect3fRotate (vect3f inVect, vect3f inAxis, float inAngle)
 This function is meant to rotate a direction vector around an axix by inAngle.
vect3f mathVect3fCrossProd (vect3f inVect0, vect3f inVect1)
float mathVect3fLength (vect3f inVect)
vect3fmathVect3fNormalize (vect3f *inVect)
vect3f mathVect3fNormal (vect3f inVect)


Function Documentation

float mathACosf ( float  inAngle  ) 

This is basically a wrapper for acosf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.

Parameters:
inAngle The angle whose arc-cosine will be calculated.
Returns:
The arc-cosine of inAngle.
See also:
FL_MATH_VFPU

Definition at line 249 of file flMath.c.

float mathATanf ( float  inAngle  ) 

This is basically a wrapper for atanf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.

Parameters:
inAngle The angle whose arc-tangent will be calculated.
Returns:
The arc-tangent of inAngle.
See also:
FL_MATH_VFPU
Warning:
A VFPU version of this function has not yet been written.

Definition at line 266 of file flMath.c.

Referenced by spriteDraw2dFrame().

float mathCosf ( float  inAngle  ) 

This is basically a wrapper for cosf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.

Parameters:
inAngle The angle whose cosine will be calculated.
Returns:
The cosine of inAngle.
See also:
FL_MATH_VFPU

Definition at line 222 of file flMath.c.

Referenced by camMoveStrafe(), camViewCalc(), graphics2dDrawEllipse(), graphics2dDrawEllipseFilledGrad(), graphics2dDrawSpheroidShaded(), graphics3dDrawSphere(), graphics3dDrawSphereTextured(), and spriteDraw2dFrame().

float mathDegToRad ( float  inDeg  ) 

Converts a degree value to radians (e.g 180 would return pi).

Parameters:
inDeg The degree value that is to be converted.
Returns:
The equivalent angle in radians.

Definition at line 157 of file flMath.c.

References MATH_PI, and mathFixDegRange().

float mathDotProdN ( float *  inValue0,
float *  inValue1,
u8  inCount 
)

This returns the dot product of inCount sets of values.

Parameters:
inValue0 An array of floats of length inCount to be dotted with inValue1.
inValue1 An array of floats of length inCount to be dotted with inValue0.
inCount The number of elements in the arrays passed.
Returns:
The dot product of inValue0 and inValue1.

Definition at line 369 of file flMath.c.

float mathExpnf ( float  inValue  ) 

This is basically a wrapper for expf from libmath, it returns the natural exponent of a number.

Parameters:
inValue The value whose natural exponent will be calculated.
Returns:
The natural exponent of inValue.

Definition at line 284 of file flMath.c.

float mathFixDegRange ( float  inDeg  )  [inline]

Fixes numbers to be within the standard range for degrees which is 0 to 360.

Parameters:
inDeg The value whose range needs to be fixed.
Returns:
The fixed range version of inDeg (e.g if inDeg = 370, 10 is returned).

Definition at line 141 of file flMath.c.

Referenced by mathDegToRad().

float mathFixRadRange ( float  inRad  )  [inline]

Fixes numbers to be within the standard range for radians which is 0 to 2pi.

Parameters:
inRad The value whose range needs to be fixed.
Returns:
The fixed range version of inRad (e.g if inDeg = 3pi, 1pi is returned).

Definition at line 149 of file flMath.c.

References MATH_PI.

Referenced by mathRadToDeg().

void mathInit (  ) 

This is called by flInitialize(), it initializes the maths system, by seeding the random number generator and if trigcaching is used then it creates the cache.

See also:
flInitialize()

Definition at line 25 of file flMath.c.

References mathRandSeed().

Referenced by flInitialize().

float mathLnf ( float  inValue  ) 

This is basically a wrapper for logf from libmath, it returns the natural logarithm of a number.

Parameters:
inValue The value whose natural logarithm will be calculated.
Returns:
The natural logarithm of inValue.

Definition at line 301 of file flMath.c.

float mathPythag2f ( float  inX,
float  inY 
)

This returns the the square root of inX^2 + inY^2.

Parameters:
inX The length of side A of a right angle triangle.
inY The length of side B of a right angle triangle.
Returns:
The length of side C of a right angle triangle.
See also:
mathPythag2f

Definition at line 332 of file flMath.c.

Referenced by spriteDraw2dFrame().

float mathPythag3f ( float  inX,
float  inY,
float  inZ 
)

This returns the the square root of inX^2 + inY^2 + inZ^2.

Parameters:
inX Size 0.
inY Side 1.
inZ Side 2
Returns:
Side 3.
See also:
mathPythag3f

Definition at line 349 of file flMath.c.

float mathQuatLength ( quat4f  inQuat  ) 

Definition at line 392 of file flMath.c.

Referenced by mathQuatNormalize().

quat4f mathQuatMult ( quat4f  inQuat0,
quat4f  inQuat1 
)

Definition at line 464 of file flMath.c.

Referenced by mathVect3fRotate().

quat4f* mathQuatNegate ( quat4f inQuat  ) 

Definition at line 450 of file flMath.c.

Referenced by mathQuatNegation(), and mathVect3fRotate().

quat4f mathQuatNegation ( quat4f  inQuat  ) 

Definition at line 458 of file flMath.c.

References mathQuatNegate().

quat4f mathQuatNormal ( quat4f  inQuat  ) 

Definition at line 444 of file flMath.c.

References mathQuatNormalize().

quat4f* mathQuatNormalize ( quat4f inQuat  ) 

Definition at line 415 of file flMath.c.

References mathQuatLength().

Referenced by mathQuatNormal().

float mathRadToDeg ( float  inRad  ) 

Converts a radian value to degrees (e.g pi/2 would return 90).

Parameters:
inRad The radian value that is to be converted.
Returns:
The equivalent angle in degrees.

Definition at line 176 of file flMath.c.

References MATH_PI, and mathFixRadRange().

float mathRandf ( float  inSize  ) 

This function returns a pseudo random number between 0 and inSize.

Parameters:
inSize The range of the random number returned.
Returns:
Pseudo-random number between 0 and inSize.

Definition at line 50 of file flMath.c.

References FL_MATH_RANDOMSEED_FREQUENCY.

float mathRandFractf (  ) 

This function returns a pseudo random number between 0 and 1.

Returns:
Pseudo-random number between 0 and 1.

Definition at line 80 of file flMath.c.

References FL_MATH_RANDOMSEED_FREQUENCY.

unsigned int mathRandi ( unsigned int  inSize  ) 

This function returns a pseudo random integer between 0 and inSize - 1, for example mathRandi(10) would return a number from 0 to 9.

Parameters:
inSize One more than the maximum integer that will be returned.
Returns:
Pseudo-random integer between 0 and inSize - 1.

Definition at line 108 of file flMath.c.

References FL_MATH_RANDOMSEED_FREQUENCY.

Referenced by colorRandom8888(), and mathRandl().

s64 mathRandl ( s64  inSize  ) 

This function returns a pseudo random integer between 0 and inSize - 1, this function is the same as mathRandi() however it uses double accuracy signed integers.

Parameters:
inSize One more than the maximum integer that will be returned.
Returns:
Pseudo-random integer between 0 and inSize - 1.
See also:
mathRandi()

Definition at line 135 of file flMath.c.

References mathRandi().

void mathRandSeed ( u32  inSeed  ) 

This function reseeds the random number generator.

Parameters:
inSeed The seed to use for random number generation.
See also:
mathRandf(), mathRandFractf(), mathRandi(), mathRandl()

Definition at line 35 of file flMath.c.

Referenced by mathInit().

float mathSinf ( float  inAngle  ) 

This is basically a wrapper for sinf from libmath, however if FL_MATH_VFPU is enabled then it will use the VFPU ro speed up the process.

Parameters:
inAngle The angle whose sine will be calculated.
Returns:
The sine of inAngle.
See also:
FL_MATH_VFPU

Definition at line 195 of file flMath.c.

Referenced by camMoveStrafe(), camViewCalc(), graphics2dDrawEllipse(), graphics2dDrawEllipseFilledGrad(), graphics2dDrawSpheroidShaded(), graphics3dDrawSphere(), graphics3dDrawSphereTextured(), and spriteDraw2dFrame().

vect3f mathVect3fCrossProd ( vect3f  inVect0,
vect3f  inVect1 
)

Definition at line 569 of file flMath.c.

float mathVect3fLength ( vect3f  inVect  ) 

Definition at line 604 of file flMath.c.

Referenced by mathVect3fNormalize().

vect3f mathVect3fNormal ( vect3f  inVect  ) 

Definition at line 649 of file flMath.c.

References mathVect3fNormalize().

vect3f* mathVect3fNormalize ( vect3f inVect  ) 

Definition at line 624 of file flMath.c.

References mathVect3fLength().

Referenced by mathVect3fNormal().

vect3f mathVect3fRotate ( vect3f  inVect,
vect3f  inAxis,
float  inAngle 
)

This function is meant to rotate a direction vector around an axix by inAngle.

Parameters:
inVect The vector to be rotated.
inAxis The axis to rotate around.
inAngle The angle to rotate by.
Returns:
The rotated vector.
Warning:
This function doesn't seem to work.

Definition at line 523 of file flMath.c.

References mathQuatMult(), and mathQuatNegate().


Generated on Wed Sep 5 19:04:02 2007 for funcLib by  doxygen 1.5.1