I have been not using math for a long time and this should be a simple problem to solve.
Suppose I have two points A: (1, 0) and B: (1, -1).
I want to use a program (Python or whatever programming language) to calculate the clockwise angle between A, origin (0, 0) and B. It will be something like this:
Use the inner product and the determinant of the two vectors. This is really what you should understand if you want to understand how this works. You'll need to know/read about vector math to understand.
from math import acos from math import sqrt from math import pi def length(v): return sqrt(v**2+v**2) def dot_product(v,w): return v*w+v*w def determinant(v,w): return v*w-v*w def inner_angle(v,w): cosx=dot_product(v,w)/(length(v)*length(w)) rad=acos(cosx) # in radians return rad*180/pi # returns degrees def angle_clockwise(A, B): inner=inner_angle(A,B) det = determinant(A,B) if det<0: #this is a quality of the det. If the det < 0 then B is clockwise of A return inner else: # if the det > 0 then A is immediately clockwise of B return 360-inner
In the determinant computation, you're concatenating the two vectors to form a 2 x 2 matrix, for which you're computing the determinant.