Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
1
Question by Luka · Apr 04, 2010 at 04:30 PM · mathtangent

problem with mathf.tan

can i calculate the angle with its tangent in a java script?

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
6
Best Answer

Answer by Cyclops · Apr 04, 2010 at 04:37 PM

It's fairly simple: Mathf.Tan(angle).

print (Mathf.Tan(0.5));

Note that the angle must be Radians, so if you have a value in Degrees, you need to convert, like this:

var deg = 45;
var rad = deg * Mathf.PI / 180;
print (Mathf.Tan(rad));
Comment
Add comment · Show 2 · 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 Peter G · Apr 04, 2010 at 08:06 PM 1
Share

or you can use $$anonymous$$ath.Rad2Deg or vice versa.

avatar image SamFernGamer4k · Jan 01, 2021 at 04:19 AM 0
Share

Thank you. I was doing the opposite and calculating the angle in degrees when it was already in degrees. That's why it wasn't working.

avatar image
2

Answer by duck · Apr 04, 2010 at 04:36 PM

Yes, you should find that Mathf.Tan works as expected. Be careful that you have capitalised it properly, and remember that the angles are given in radians for the maths functions.

If you're having a particular problem, please give more detail.

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 Cyclops · Apr 04, 2010 at 04:38 PM 0
Share

Dang, missed by that much...

avatar image duck ♦♦ · Apr 04, 2010 at 06:32 PM 0
Share

Unity also has some helper math functions to convert to and from radians, here: http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=mathf+deg+rad

avatar image Cyclops · Apr 04, 2010 at 06:38 PM 0
Share

@Duck, I didn't know about those - and that's why you're preparing to ascend to become a Unity Demigod. :)

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

1 Person is following this question.

avatar image

Related Questions

Why am I not getting an angle in degrees from aTan? 1 Answer

calculus help angels of a triangle 1 Answer

Help with strings and decimals 1 Answer

Optimising projectile continuously calculated impact point 2 Answers

Sphere coords, radiating from centre. 0 Answers


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