Computer Science Canada

equivalent to cosd

Author:  Homer_simpson [ Mon Jun 23, 2003 6:19 pm ]
Post subject:  equivalent to cosd

what's the equivalent for the turing command "cosd" in c++?

Author:  Mazer [ Mon Jun 23, 2003 6:40 pm ]
Post subject: 

i can't seem to find one... not that i've looked that thoroughly, i'm still pretty n00bish at C++. but it seems to me that a good site would be www.cprogramming.com
they have a (rather incomplete) listing of C++ functions. there were a few trig ones but they aren't the same as the sind and cosd of turing.

Author:  Mazer [ Mon Jun 23, 2003 6:44 pm ]
Post subject: 

wait... it turns out you can use plain old 'cos' or 'sin'. just one catch: the parameter is in radians. i think the ratio for converting degrees to radians is (Pi*degrees)/180

but then again, i suck at math Laughing

Author:  AsianSensation [ Mon Jun 23, 2003 6:46 pm ]
Post subject: 

I don't think there is one in C, I think you have to make it urself, just convert radians to degrees or something, I think martin made something like this.

Author:  Mazer [ Mon Jun 23, 2003 6:53 pm ]
Post subject: 

code:

double deg2rad (double degrees)
    {
    double radians = (3.141592653*degrees)/180;
    return
    }


like that i guess. then it'd be:

code:

cout << cos (deg2rad(45));


EDIT: of course, don't forget to include math.h if you haven't already.

Author:  Homer_simpson [ Mon Jun 23, 2003 8:05 pm ]
Post subject: 

Doh!!!!! I am an idiot... =S
y didn't i think of that....i just studied that last semester Laughing
thx ppl problem solved...


: