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
0
Question by smirlianos · Aug 24, 2013 at 11:58 AM · mathfreturntriangledegree

What's wrong with this type?

Hello,

I want to find the 3 corners of a triangle.

I use this to print each corner but it always gives me approximately the same result for each corner.

What's wrong?

 var Cdegree = Mathf.Rad2Deg * ( Mathf.Acos( (Mathf.Sqrt(a) + Mathf.Sqrt(b) - Mathf.Sqrt(c)) / (2 * a * b) ) );
 print (Cdegree);
 var Bdegree = Mathf.Rad2Deg * ( Mathf.Acos( (Mathf.Sqrt(a) + Mathf.Sqrt(c) - Mathf.Sqrt(b)) / (2 * a * c) ) );
 print (Bdegree);
 var Adegree = Mathf.Rad2Deg * ( Mathf.Acos( (Mathf.Sqrt(b) + Mathf.Sqrt(c) - Mathf.Sqrt(a)) / (2 * b * c) ) );
 print (Adegree);
Comment
Add comment · Show 5
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 LemonLake · Aug 24, 2013 at 12:04 PM 0
Share

Didn't you post two similar questions? http://answers.unity3d.com/questions/523159/whats-wrong-with-this-algorithm.html http://answers.unity3d.com/questions/523128/move-spheres-to-form-triangle.html

avatar image smirlianos · Aug 24, 2013 at 12:06 PM 0
Share

They have the same topic, but they're totaly different... The first is how to arrange some gameObjects The second is what was the problem of an allgorithm And the third, this, is why the results are same with 3 different allgorithms...

avatar image LemonLake · Aug 24, 2013 at 12:08 PM 0
Share

Try printing the values of a, b and c.

avatar image smirlianos · Aug 24, 2013 at 12:12 PM 0
Share

These are the 3 distances between the 3 corners a = 2 b = 5.8 c = 5.4

avatar image LemonLake · Aug 24, 2013 at 12:13 PM 0
Share

Have a look at CHPedersen's post

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by CHPedersen · Aug 24, 2013 at 12:10 PM

I think you've got the formulae wrong. You're using the law of cosines, but a, b and c should be squared in the numerator of those fractions, not square-rooted. Mathf.Sqrt is the square root, not the square.

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 smirlianos · Aug 24, 2013 at 12:14 PM 0
Share

How I put the squared numbers? a * a?

avatar image CHPedersen · Aug 24, 2013 at 12:17 PM 1
Share

Yep. Just multiply them with themselves. Do it before the formulae and store the squared result in separate variables, so you don't force the CPU to do the same multiplication every time a square is needed (each is needed 3 times).

avatar image smirlianos · Aug 24, 2013 at 12:23 PM 0
Share

Thanks, All is working now!

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

17 People are following this question.

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

Related Questions

What's wrong with this algorithm? 2 Answers

place 8 objects around a target gameObject in a circle ( like a compass ) 3 Answers

Move spheres to form triangle 1 Answer

How do I get the 'normal' Sinus? 1 Answer

How to find inverse cos 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