Some math functions...


Defines

#define XF_Cos(angle)   XF_SIN[((angle) + 128)&511]
 Returns the Cos value for an angle. The value goes from -256 to 256... Watch out though : the angle is not in 360 degrees, but in 512 !
#define XF_Sin(angle)   XF_SIN[((angle))&511]
 Returns the Sin value for an angle. The value goes from -256 to 256... Watch out though : the angle is not in 360 degrees, but in 256 !

Functions

u16 XF_AdjustAngle (u16 angle, s16 anglerot, s32 startx, s32 starty, s32 targetx, s32 targety)
 Adjust an angle, for example to calculate in which direction an object shoudl turn Base angle, from 0 to 511 For how much to turn... Initial X position Initial Y position Target X position Target Y position.
u16 XF_GetAngle (s32 startx, s32 starty, s32 targetx, s32 targety)
 Get the angle, from 0 to 511, formed between the horizontal and the line Initial X position Initial Y position Target X position Target Y position.
s64 XF_Distance (s32 x1, s32 y1, s32 x2, s32 y2)
 Calculate the distance (squared) between 2 points X coordinate of the fist point Y coordinate of the first point X coordinate of the second point Y coordinate of the second point.

Detailed Description

Adjust angles, get random values...

Define Documentation

#define XF_Cos ( angle   )     XF_SIN[((angle) + 128)&511]

Returns the Cos value for an angle. The value goes from -256 to 256... Watch out though : the angle is not in 360 degrees, but in 512 !

Definition at line 21 of file xf_math.h.

#define XF_Sin ( angle   )     XF_SIN[((angle))&511]

Returns the Sin value for an angle. The value goes from -256 to 256... Watch out though : the angle is not in 360 degrees, but in 256 !

Definition at line 29 of file xf_math.h.


Function Documentation

u16 XF_AdjustAngle ( u16  angle,
s16  anglerot,
s32  startx,
s32  starty,
s32  targetx,
s32  targety 
)

Adjust an angle, for example to calculate in which direction an object shoudl turn Base angle, from 0 to 511 For how much to turn... Initial X position Initial Y position Target X position Target Y position.

Definition at line 11 of file xf_math.c.

inline s64 XF_Distance ( s32  x1,
s32  y1,
s32  x2,
s32  y2 
) [inline]

Calculate the distance (squared) between 2 points X coordinate of the fist point Y coordinate of the first point X coordinate of the second point Y coordinate of the second point.

Definition at line 98 of file xf_math.h.

u16 XF_GetAngle ( s32  startx,
s32  starty,
s32  targetx,
s32  targety 
)

Get the angle, from 0 to 511, formed between the horizontal and the line Initial X position Initial Y position Target X position Target Y position.

Definition at line 43 of file xf_math.c.


Generated on Wed Dec 12 23:46:48 2007 for XFlib by  doxygen 1.5.4