• Advertisement

Archived

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

Sin & Cos lookup table

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
take your time:



#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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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
www.google.com

Share this post


Link to post
Share on other sites

  • Advertisement