I have a triangle made of 3 vertices. I need to know what the angle of the triangle is.
How would I go about it?
I have a triangle made of 3 vertices. I need to know what the angle of the triangle is.
How would I go about it?
Cos rule. a^2 = b^2 + c^2 - 2 b c cos A
Edit: although if you’re talking about a situation where numerical analysis matters then read http://www.cs.berkeley.edu/~wkahan/Triangle.pdf
My bad. It’s 2 points, not a triangle :persecutioncomplex:
Alright, so I got two vectors that each contain a x y and z. We’ll call them a and b.
I create a new point in the middle of the two points.
Vector3 middle = new Vector3(//order x,y,z
(max.getX() - min.getX())/2,
(max.getY() - min.getY())/2,
(max.getZ() - min.getZ())/2
);
To get the y angle I use the formula Math.toDegrees(Math.atan2(middle.getX(), middle.getZ()))
That’s not in the middle, except in some special cases. It’s half the vector from one to the other. The division by 2 is pretty pointless if the only thing you’re going to do is call atan2.
I’m still not quite sure what you’re trying to do. Compute Euler angles for a look vector?
I’m still not understanding the question. If it is “What’s the angle between ‘A’ & ‘B’”, then like SimonH’s reply - use the dot product (SEE: Geometric interpretation).