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 /
avatar image
2
Question by skitch · May 29, 2012 at 06:42 PM · mathfdegreesmathf.sin

Convert Mathf.Sin() radians to degrees

Hi.

I need to display some calculations on my screen, and I want to show some of them in degrees. The problem is taht unity calculates perfectly sin and cos in radians but I cant get it to convert them properly to degrees.

I've used the Rad2Deg variable, and even try it by the "manual way" like this:

cosOps=(360*Mathf.Sin(45))/2*Mathf.PI;

Thanks for the help!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by whydoidoit · May 29, 2012 at 06:48 PM

It's looking for the parameter of Mathf.Sin to be in radians. The return value is going to be the resulting sin value. Mathf.Asin will return an angle in radians from a sin.

EDIT

Ok I'm going to try this again!

If you want to be able to input angles in degrees then you need to convert the angle you input into radians before getting the sine of the angle.

   var myAngleInDegrees = 175;
   var sinOfAngle = Mathf.Sin((myAngleInDegrees * Mathf.PI)/180);

if you have the sine of an angle and you want the angle in degrees

    var mySineOfAngle = 0.4;
    var angleOfSineInDegrees = (Mathf.ASin(mySineOfAngle) * 180) / Mathf.PI;
Comment
Add comment · Show 3 · 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 skitch · May 29, 2012 at 08:45 PM 0
Share

Sorry I don't think I've understood your answer.

avatar image whydoidoit · May 29, 2012 at 08:55 PM 0
Share

So Sin(45) looks like an angle in degrees. The Sin of an angle is going to be between -1 and 1 - so you can't convert that to anything using radians to degrees or whatever.

The ASin of a sine is going to return an angle in radians - you might want to convert that to degrees.

Hey - I just can't write the comment right - tried 3 times - must be tired :)

avatar image whydoidoit · May 29, 2012 at 09:02 PM 0
Share

And for further clarification of my very murky comment $$anonymous$$ath.Sin expects to be given an angle in radians not in degrees. $$anonymous$$athf.Sin($$anonymous$$athf.PI)

avatar image
1

Answer by threeup · May 29, 2012 at 10:27 PM

PI by 180 or 180 by PI is the ratio to use. General rule , if it is a big number ( 0 to 360) divide by 180, if it is small number (-1 to 1) multiply by 180.

angleDeg = 45f; angleRad = angleDeg * PI / 180;

sinAngleRad = Mathf.Sin(angleRad); sinAngleDeg = sinAngleRad*180/PI;

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

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

Mathf.Sin() & Mathf.Cos() 1 Answer

Clamp rotation of sprite? 0 Answers

How does this AND Mathf.Sin actually work?! 2 Answers

Snap the rotation 0 Answers

tangents from angle gives weird results 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