First of all, I apologize to post this easy question. Probably there is a module to compute angle and distance between two points.
Given

you could compute the angle, theta, and the distance between A and B with:
import math
def angle_wrt_x(A,B):
"""Return the angle between B-A and the positive x-axis.
Values go from 0 to pi in the upper half-plane, and from
0 to -pi in the lower half-plane.
"""
ax, ay = A
bx, by = B
return math.atan2(by-ay, bx-ax)
def dist(A,B):
ax, ay = A
bx, by = B
return math.hypot(bx-ax, by-ay)
A = (560023.44957588764, 6362057.3904932579)
B = (560036.44957588764, 6362071.8904932579)
theta = angle_wrt_x(A, B)
d = dist(A, B)
print(theta)
print(d)
which yields
0.839889619638 # radians
19.4743420942
(Edit: Since you are dealing with points in a plane, its easier to use atan2 than the dot-product formula).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With