Amulets & Armor  v1.02
Open Source Game
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions | Variables
_3D_TRIG

3D Math routines More...

Macros

#define M_PI   (3.14159265358979323846)
 
#define M_PI_2   (1.57079632679489661923)
 

Functions

T_void IMathPower2Init (T_void)
 
T_void ISetupViewTable (T_void)
 
T_word16 MathArcTangent (T_sword32 y, T_sword32 x)
 
T_word16 MathArcTangent32 (T_sword32 y, T_sword32 x)
 
T_word16 MathArcTangentOld (T_sword16 y, T_sword16 x)
 
T_sword32 MathCosine (T_word16 angle)
 
T_void MathFinish (T_void)
 
T_void MathInitialize (T_word32 screenWidth)
 
T_void MathInitializeInvDistTable (T_word32 screenWidth)
 
T_void MathInitializeOld (T_word32 screenWidth)
 
T_sword32 MathInvCosine (T_word16 angle)
 
T_sword32 MathSine (T_word16 angle)
 
T_sword32 MathTangent (T_word16 angle)
 
T_sword16 MathXTimesCosAngle (T_sword16 x, T_word16 angle)
 
T_sword16 MathXTimesSinAngle (T_sword16 x, T_word16 angle)
 

Variables

T_word16 G_arcTanTable [256][256]
 
T_sword32 G_cosTable [MATH_MAX_ANGLE]
 
T_sword32 G_invCosTable [MATH_MAX_ANGLE]
 
T_sword32 G_invDistTable [MATH_MAX_DISTANCE]
 
T_byte8 G_power2table [257]
 
T_sword32 G_sinTable [MATH_MAX_ANGLE]
 
T_sword32 G_tanTable [MATH_MAX_ANGLE]
 
T_byte8 G_translucentTable [256][256]
 
T_sword32 G_viewTanTable [MAX_VIEW3D_WIDTH]
 

Detailed Description

3D Math routines

All of the 3D Math goes here.

See Also
http://www.amuletsandarmor.com/AALicense.txt

Macro Definition Documentation

#define M_PI   (3.14159265358979323846)

I want my own constants for pi and pi/2.

#define M_PI_2   (1.57079632679489661923)

Function Documentation

T_void IMathPower2Init ( T_void  )
T_void ISetupViewTable ( T_void  )

ISetupViewTable

T_word16 MathArcTangent ( T_sword32  y,
T_sword32  x 
)

MathArcTangent takes the given x and y deltas and determines the atan (using this system's theta values).

Parameters
y– Numerator of tangent fraction
x– Denomator of tangent fraction
Returns
Angle result
T_word16 MathArcTangent32 ( T_sword32  y,
T_sword32  x 
)

MathArcTangent32 is a 32 bit version of MathArcTangent

Parameters
y– Numerator of tangent fraction
x– Denomator of tangent fraction
Returns
Angle result
T_word16 MathArcTangentOld ( T_sword16  y,
T_sword16  x 
)
T_sword32 MathCosine ( T_word16  angle)

Calculates 32768 * cos(angle) and returns in integer format.

NOTE: This routine is only called during the trig initialization process.

Parameters
angle– Degrees of angle to report sine of
T_void MathFinish ( T_void  )

MathFinish is called when the lookup tables are no longer needed. They are all unloaded.

T_void MathInitialize ( T_word32  screenWidth)

MathInitialize creates all the lookup tables used by the math routines. Some of the tables (well, one) needs the width of the screen as well. Pass this in to the routine. This routine MUST be called before all other routines are used.

Parameters
screenWidth– Width of view screen.
T_void MathInitializeInvDistTable ( T_word32  screenWidth)

MathInitializeInvDistTable calculates the inverse distance table based on the given width of the screen. All perspective calculations are based on this table instead of using division during the rendering process. Call this routine at any time the width of the view is changed.

Parameters
screenWidth– Width of the screen
T_void MathInitializeOld ( T_word32  screenWidth)
T_sword32 MathInvCosine ( T_word16  angle)

Calculates 1/(65536 * cos(angle)) and returns in integer format.

NOTE: This routine is only called during the trig initialization process.

Parameters
angle– Degrees of angle to report sine of
Returns
1/(65536 * cos(angle))
T_sword32 MathSine ( T_word16  angle)

Calculates 32768 * sin(angle) and returns in integer format.

NOTE: This routine is only called during the trig initialization process.

Parameters
angle– Degrees of angle to report sine of
T_sword32 MathTangent ( T_word16  angle)

Calculates 32768 * tan(angle) and returns in integer format.

NOTE: This routine is only called during the trig initialization process.

Parameters
angle– Degrees of angle to report sine of
T_sword16 MathXTimesCosAngle ( T_sword16  x,
T_word16  angle 
)

Computes x * cos(angle)

Parameters
x– Multiplier
angle– Angle
Returns
x * cos(angle)
T_sword16 MathXTimesSinAngle ( T_sword16  x,
T_word16  angle 
)

Computes x * sin(angle)

Parameters
x– Multiplier
angle– Angle
Returns
x * sin(angle)

Variable Documentation

T_word16 G_arcTanTable[256][256]
T_sword32 G_invCosTable[MATH_MAX_ANGLE]
T_sword32 G_invDistTable[MATH_MAX_DISTANCE]
T_byte8 G_power2table[257]
T_byte8 G_translucentTable[256][256]
T_sword32 G_viewTanTable[MAX_VIEW3D_WIDTH]