- Home /
The question is answered
I can't find cossine.
It's working well for Sine but not Cossine:
print ("Sin "+Mathf.Sin(89 * Mathf.PI / 180));
print ("Cossine"+Mathf.Cos(89 * Mathf.PI / 180));
print ("Sin "+Mathf.Sin(90 * Mathf.PI / 180));
print ("Cossine"+Mathf.Cos(90 * Mathf.PI / 180));
print ("Sin "+Mathf.Sin(91 * Mathf.PI / 180));
print ("Cossine"+Mathf.Cos(91 * Mathf.PI / 180));
Sin 0.9998477 Cossine 0.01745238 Sin 1 Cossine -4.371139E-08 Sin 0.9998477 Cossine -0.01745247
Thanks.
A 0.02 margin of error seems respectably small to me. Can you state why you need greater precision? I'm going to assume the error is due to the limits of floating point precision.
Where is the problem? It is suppose to be 0 and -4.371139E-08 is very close to it. Float isn't 100% accurate.
Cosine of 90 is not -4.37.
Unity isn't clai$$anonymous$$g that it is. It says that the cosine of 90 * $$anonymous$$athf.PI / 180 is "-4.371139E-08", which is correct as far as single-precision floating point goes (that is, nearly 0), and is far away from -4.37. Are you aware of scientific notation? http://en.wikipedia.org/wiki/Scientific_notation#E_notation
You can always use doubles ins$$anonymous$$d of singles if you want more precision. The $$anonymous$$athf stuff is just a wrapper for System.$$anonymous$$ath functions (which use doubles) anyway.
Those aren't worse results, they're better. You don't seem to understand scientific notation; please read the link I posted. The results are not less than -1 or greater than 1.
-2.44921270764475E-16 That means -0.000000000000000244921270764475
E"XX" means that you have to multiply it by 10^XX (adding '0' to the right when XX is positive, and to the left when negative).
float is not a precise type, so a bit of margin like this is expected.
Answer by Kiwasi · Nov 05, 2014 at 02:38 AM
The correct way to read -4.371139E-08 is -0.00000004371139. That is as close to zero as makes no difference.
There is also no such thing as cossine. The correct term is cosine.
Closing this question before you embarrass yourself any further.
At first time, I am not in a English forum, your advices in this issue are welcome though if they were in a suitable way. English is not my first language so is normal to make some mistake as well, just as you would if you had to learn Portuguese, I think a little bit more. And sorry if I didn't learn scientific notation at my $$anonymous$$BA, that was this forum suppose to be about: Unity, program$$anonymous$$g and maybe because of it a little bit of exact sciences...
You are asking for help from a community of unpaid strangers. Take what you can get and consider yourself ahead of the game.
Yes, that's the exactly definition of what we call it online forum. Thanks. I already talked a lot with in this 'unpaid strangers' since the web began in this "communities", and their behavior were a little different of yours... Believe or not I am some of this forums someone who helps, and my believe is that: Paid or not, you are helping because you want, you are not forced to do, if if you commit yourself to do a thing is presumed that you the right way. When I don't want do a thing I humbly pass. Do you understand?
Not really understanding you, your English is difficult to follow. Either way, you now know about scientific notation and a little about floating point accuracy.
Good luck as you continue with learning Unity.