Entelicon
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 1002 |
|
|
| 03 Aug 2016 05:29 AM |
I have two Vector coordinates a = {5,10} b = {7,17}
How do I find the angle between those two coordinates?
I've heard the the dot product can help me but it honestly confuses me and I dont know what to do. |
|
|
| Report Abuse |
|
|
Laedere
|
  |
| Joined: 17 Jun 2013 |
| Total Posts: 23601 |
|
|
| 03 Aug 2016 05:36 AM |
| math.atan2(b[2] - a[2], b[1] - a[1]) * (180 / math.pi) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:38 AM |
Since it's 2 2D points, you can use inverse tangent without any effort puu.sh/qoiqb/c41f86e199.png
You can use atan2 so you can get a range (-pi, pi] or if you add pi: [0, 2pi) instead of a range of (-pi/2, pi/2) using atan.
local angle = math.atan2(b[2] - b[1], a[2] - a[1]) |
|
|
| Report Abuse |
|
|
|
| 03 Aug 2016 05:39 AM |
I wrote the coordinates down wrong. I plotted 5, 17; 7, 10 but accidentally put 5, 10; 7, 17.
woops |
|
|
| Report Abuse |
|
|