Posts: 157
Threads: 38
Joined: May 2012
Reputation:
0
Well I Need A Function That Calculates An Angle Between 3 Points
Posts: 1,849
Threads: 96
Joined: Apr 2010
Reputation:
0
Could you please Elaborate? Which angle are you talking about? Can you explain with a Picture?
Posts: 1,046
Threads: 29
Joined: Mar 2010
acos( (vector a * vector b) / ( vector lenght a * vector lenght b) ) = angle
Posts: 157
Threads: 38
Joined: May 2012
Reputation:
0
could u please explain i know only the basics of trigonometry vectors and so
Posts: 1,464
Threads: 11
Joined: Jan 2008
Reputation:
0
By using GetAngleBetweenPoints-function find the angles between point 2 and point 1 as well as point 2 and point 3, then just calculate the difference between those two angles.
Posts: 1,046
Threads: 29
Joined: Mar 2010
Both vectors have their x, y, and z. Let's define the "vector a" by doing "point 1" - "point 2", and define "vector b" by doing "point 3" - "point 2".
For the angle caclulation you have to first calculate (vect_a_x*vect_b_x)+(vect_a_y*vect_b_y)+(vect_a_z* vect_b_z). If this value equals zero, you have obviosly a 90° radius.
If not, you have to divide it by sqrt((vect_a_x*vect_a_x)+(vect_a_y*vect_a_y)+(vect _a_z*vect_a_z)) * sqrt((vect_b_x*vect_b_x)+(vect_b_y*vect_b_y)+(vect _b_z*vect_b_z)). the result should be insterted into acos, and you'll get your result.
Код:
acos(((vect_a_x*vect_b_x)+(vect_a_y*vect_b_y)+(vect_a_z*vect_b_z))/(sqrt((vect_a_x*vect_a_x)+(vect_a_y*vect_a_y)+(vect_a_z*vect_a_z))*sqrt((vect_b_x*vect_b_x)+(vect_b_y*vect_b_y)+(vect_b_z*vect_b_z))))