Mail Archives: djgpp/1998/07/10/11:09:52
Hi
I'm learning how to make a ray casting engine, i'm using
djgpp, and a friend of mine sent me some source code, but
i have a problem with look up tables.
I usually calculate them in this way
#include <math.h>
float tan_table[320];
float rad;
for(ang=0;ang<320;ang++)
{
rad= ang *(pi/180);
tan_table[ang]=tan(rad);
}
but i was cheking out my friend's code and found
#include <math.h>
#define ANG_360 1920
#define ANG_0 0
#define PI 3.1415927
#define TWOPI ( 2 * PI)
#define TWOPIDIV360 ( TWOPI / ANG_360)
float *tan_table;
tan_table = (float *) malloc( sizeof(float) * ANG_360);
for(angulo=ANG_0;angulo<=ANG_360;angulo++)
{
ang_rad = ang * TWOPIDIV360 ;
tan_table[ang] = (float)tan(ang_rad);
}
i have no problem with malloc and c stuff
I don't understand why he uses this formula
ang_rad = ang * TWOPIDIV360 ;
insted of the one i'm using
and why he says that 1920 is equivalent to 360
any help will be apreciated
than you.
- Raw text -