MATLAB: Calculate an angle and distance from three points

angledistancethree points

hi…How to calculate an angle and distance from three points? ex P1 = (x=2, y=50) P2 = (x=9, y=40) P3 = (x=5, y=20)

Best Answer

I'll show you how to find one of the angles in the triangle P1 = [x1;y1], P2 = [x2;y2], P3 = [x3;y3]. The inner angle at vertex P1 is given by:
A1 = atan2(abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)), ...
(x2-x1)*(x3-x1)+(y2-y1)*(y3-y1));
As for the "distance", please tell us what kind of distance you have in mind. Distance from what to what?