www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/10/11:09:52

Message-ID: <35A62FBB.AF821E92@cue.satnet.net>
Date: Fri, 10 Jul 1998 10:14:05 -0500
From: "Ronald Patiño G" <logan AT cue DOT satnet DOT net>
MIME-Version: 1.0
To: "djgpp AT delorie DOT com" <djgpp AT delorie DOT com>
Subject: About ray casting and look up tables

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019