sin, cos, tan calculations incorrect?

Posted By: Trooper119

sin, cos, tan calculations incorrect? - 09/06/08 23:49

This might currently be known, perhaps not, but I have a strange issue I'd like to run past you guys before I submit this in the bug section. Why is it if I have the following code:
Code:
fcos(90, 1);
fsin(90, 1);
ftan(90, 1);
cos(90);
sin(90);
tan(90);

Keep in mind according to the manuel all fsin, fcos, and ftan do is do something similar to the following. (But does it more accurately in some way)
Code:
fcos(x, y)
{
   y*cos(x);
}

Now anyone who knows the properties of sin, cos, and tangent knows that my code at the top should return the results
fcos(90, 1); = 0
fsin(90, 1); = 1
ftan(90, 1); = Infinity
cos(90); = 0
sin(90); = 1
tan(90); = Infinity

However when looking at the results in game they actually give
fcos(90, 1) = 0 //Correct
fsin(90, 1) = 1 //Correct
ftan(90, 1) = 2097152 //Close enough, we can ignore it doesn't give an error, actually we prefer this
cos(90) = -0.448 //Say what?
sin(90) = 0.894 //Now I'm confused
tan(90) = -1.995 //Where do these come from?

Also looking at the acos, asin, and atan give strange numbers as well where the facos, fasin, and fatan give more expected results.

Upon doing all of this I realized one thing, are these their Radian answers for whatever reason? Anyway I'm confused on the results, and with the help of fcos, fsin and ftan I can get the answer I want, but I would like a solution to this issue if anyone knows it.
Posted By: JibbSmart

Re: sin, cos, tan calculations incorrect? - 09/07/08 00:11

yes, they're in radians. they are either float or double trigonometric functions, and when you stick a constant in there, a7 assumes you are calling the float/double version. if you used vars you'd get the var version, which uses degrees. or, if you want to make sure it uses degrees call sinv, cosv, tanv, asinv, acosv, atanv.

i think it's because radians are the standard unit of measure for angles, so conitec wanted to move to using those without losing backwards compatibility with those using degrees.

julz
Posted By: Trooper119

Re: sin, cos, tan calculations incorrect? - 09/07/08 00:46

I appreciate it does seem strange that sin, cos and tan all use radians while fsin, fcos, and ftan all use degrees. I guess technically it isn't a bug according to what you said, it is strange to say the least though.

Thanks for the response.
Posted By: Tobias

Re: sin, cos, tan calculations incorrect? - 09/07/08 11:05

The reason is that in standard C, sin and cos are using radians. But var variables are using degrees.
© 2024 lite-C Forums