SA-MP Forums Archive
GetAngleBetween3Points - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: GetAngleBetween3Points (/showthread.php?tid=451289)



GetAngleBetween3Points - Opah - 16.07.2013

Well I Need A Function That Calculates An Angle Between 3 Points


Re: GetAngleBetween3Points - Ballu Miaa - 16.07.2013

Could you please Elaborate? Which angle are you talking about? Can you explain with a Picture?


Re: GetAngleBetween3Points - Opah - 17.07.2013




AW: GetAngleBetween3Points - BigETI - 17.07.2013

acos( (vector a * vector b) / ( vector lenght a * vector lenght b) ) = angle


Re: GetAngleBetween3Points - Opah - 17.07.2013

could u please explain i know only the basics of trigonometry vectors and so


Re: GetAngleBetween3Points - Finn - 17.07.2013

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.


Re: GetAngleBetween3Points - RyDeR` - 17.07.2013

Quote:
Originally Posted by Opah
Посмотреть сообщение
Not sure how that's the angle between 3 points. As far as I derive from the picture, you have Point1 and Point3 and you'd like to calculate Point2. If that's the case, you just have to do this:
pawn Код:
atan((Point1Y - Point3Y) / (Point1X - Point3X))



AW: GetAngleBetween3Points - BigETI - 17.07.2013

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))))



Re: GetAngleBetween3Points - Opah - 17.07.2013



I want measure of angle (BВC)


Re: GetAngleBetween3Points - Opah - 17.07.2013

ok Thanx Now I get it