Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Nov 05, 2014 at 02:38 AM by Kiwasi for the following reason:

The question is answered

avatar image
-3
Question by TheJayyBe · Nov 04, 2014 at 11:36 PM · mathcossine

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.

Comment
Add comment · Show 7
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlwaysSunny · Nov 04, 2014 at 11:20 PM 1
Share

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.

avatar image devluz · Nov 04, 2014 at 11:42 PM 1
Share

Where is the problem? It is suppose to be 0 and -4.371139E-08 is very close to it. Float isn't 100% accurate.

avatar image Eric5h5 · Nov 04, 2014 at 11:48 PM 2
Share

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.

avatar image Eric5h5 · Nov 05, 2014 at 02:30 AM 1
Share

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.

avatar image slay_mithos · Nov 05, 2014 at 02:35 AM 2
Share

-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.

Show more comments

1 Reply

  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TheJayyBe · Nov 05, 2014 at 04:33 AM 0
Share

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...

avatar image Kiwasi · Nov 05, 2014 at 04:56 AM 0
Share

You are asking for help from a community of unpaid strangers. Take what you can get and consider yourself ahead of the game.

avatar image TheJayyBe · Nov 05, 2014 at 05:48 AM 0
Share

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?

avatar image Kiwasi · Nov 05, 2014 at 06:58 AM 0
Share

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.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to obtain sine/cosine by angles giving me imprecise values 1 Answer

Math - Changing the frequency of a sine wave in real-time 1 Answer

Top down wasd movement dependent on rotation of the character - Mathematical problem!!! 2 Answers

Sine Wave Without the SIne Function? 3 Answers

Trying to move an object towards another's axis. 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges