# sin() and cos() that use degrees

This is a discussion on sin() and cos() that use degrees within the C Programming forums, part of the General Programming Boards category; Hi all, I was wondering if anyone knew of versions of sin() and cos() that use degrees. RHIDE's sin() and ...

1. ## sin() and cos() that use degrees

Hi all,

I was wondering if anyone knew of versions of sin() and cos() that use degrees. RHIDE's sin() and cos() use radians. I know how to convert between radians and degrees, but it doesn't work.

When I display a bitmap at the equivalent of 90 degrees, it's slightly off, because (I assume) of inaccuracies in converting between radians and degrees. Or is it inaccuracies with floating point numbers? Either way, could someone point me to a degrees version if cos() and sin()? I already tried using google but didn't get too much information.

DWK

2. You tried this? Make sure you're using doubles they have double precision.

Code:
double sind(double angle)
{
double angleradians = angle * M_PI / 180.0f;
return sin(angleradians) * M_PI / 180.0f;
}
salem knows best

3. Well it's down to inaccuracies for sure. Besides, any degree version will simply call the radian version behind your back without you realising it, so it doesn't save anything.

Or you could define
Code:
double sintable[90];
Making sure the cardinal points are set correctly, and using a loop calling sin() to initialise the rest.

4. Okay, thanks. I'll try that.