- Home /
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);
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...
These are the 3 distances between the 3 corners a = 2 b = 5.8 c = 5.4
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.
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).
Your answer
Follow this Question
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