Select to view content in your preferred language

How to find angle between 3 points

1063
1
03-18-2019 11:50 PM
Girishchandra_Yendargaye
Occasional Contributor

Can you please tell us how to find angle between 3 points

Tags (1)
0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

a programming language agnostic definition would be

take 3 sequential points  p0, p1, p2, subtract their coordinates and determine their respective angles, then derive the differences

    (d1_x, d1_y) = d1 = p0 - p1  yields the differences in the x and y coordinates
    (d2_x, d2_y) = d2 = p2 - p1  ditto
    ang1 = arctan2(d1_y, d1_x)  (d1's y, and x differences)
    ang2 =arctan2(d2_y, d2_x)
    ang = (ang2 - ang1)

    ang_deg = degrees(ang)    to convert from radians to degrees if needed

note you need your language's implementation of arctan2 not atan and that most use arctan(dy, dx) unlike spreadsheets which reverse these.  This avoids messy uses of arccos and dot products as normally shown in textbook equations

0 Kudos