• ### What is your GameDev Story?

#### Archived

This topic is now archived and is closed to further replies.

# Sin & Cos lookup table

This topic is 5634 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I''m using a fixed point math on my calculations with 24bits integral part and 8 bit fractions part. Can somebody tell me how to create a sin / cos lookup table with that precision for my trigonometry calculations ?? Thank you ...

##### Share on other sites
very carefully ,:o)

##### Share on other sites

#define DEGTORAD (M_PI/180)typedef long fixed;fixed sin_table[360],      cos_table[360];void init_tables(void){   int i;   double val;   for(i = 0;i < 360;i++)   {       val = (double)i*DEGTORAD;       sin_table[i] = sin(val)*256;       cos_table[i] = cos(val)*256;   }}`

Cheers!

"Tonight we strike,there is thunder in the sky,together we''ll fight,some of us will die,but they''ll always remember that we''ve made a stand and many will die by hand!" - ManOwaR

##### Share on other sites
Yeah, the reason why I''m posting this thread is that I don''t have a sin function to generate sin value at the first place with the addition I don''t have a float data type !!,
Can somebody tell me how can I generate sin value using fixed point math ??

##### Share on other sites
You could just hardcode the values

##### Share on other sites
Seriously, look into MacLaurin Series and Taylor Series. There are ways to build infinite geometric (or otherwise) series that converge on specific values of trigonometric functions.

Later,
ZE.

##### Share on other sites
just hardcode, its the easiest way.. if you want to just use a lookuptable anyways.

create the program on a platform where you have an fpu and sinf instruction, and let it output fixed sin[360] = { ...,..,..,..,.. }; and then copy paste that.

i''ve done that yet, too

"take a look around" - limp bizkit

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 16
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634094
• Total Posts
3015497
×