PDA

View Full Version : easiest way to find angle btween 2 points?



07-06-2000, 10:54 AM
Can someone give me the solution in simple trig?

ngill
07-06-2000, 02:26 PM
Two points constitute a line, but however if you are talking about two vectors from the origin, then we can find the angle between those VECTORS.

GLfloat findangle(vector one, vector two)
{
GLfloat dotproduct=one.x*two.x + one.y*two.y + one.z*two.z;
GLfloat cosangle(dotproduct/(one.length*two.length));
return acos(cosangle);
}