GP32 sin, cos, tan tables


metellius

Still Fresh
Joined
May 24, 2003
Messages
6
hello
i can't get sin(), cos(), tan() to work, even when including math.h, but still, all i want is just the source for a sin table, a cos table and a tan table. Can someone give it to me?

metellius
 
Don't use that trig table, I ended up wasting about an hour of messing around getting to work.

There is an easy way to get math working.
Assuming you're using GCC + devkitadv + chn's stuff (basically, devkitadv.rar from my site):

Open gp32.mk in c:\devkitadv or wherever

Look for the line
GPLIBS=-lgpsdk -lgpgraphic -lgpmem -lgpos -lgpstdlib -lgpstdio -lgpsound -lgpfont -lgpg_ex0

Add -lm to the end

Save

#include "math.h"

Use sin, cos, tan as normal.

Easiest way is obviously

int sine[256];
int cose[256];

/* LUT */
for(i=0;i<256;i++)
{
sine=(sin(i*0.02454))*256;
cose=(cos(i*0.02454))*256;
}

Then use angles 0-255, and >> 8 them.

Btw this will be in tutorial #3 and -lm will be linked by default in next devkit release.
 
You dont use the table you use the sin and cos routines that come with the file.
 
Back
Top