I have a List L
with some terms like range(2,3),
where the first element is the term with the lowest Y, now I need to sort the other elements of the list L (the first element will remain unchanged), I need to sort them by polar angle in counterclockwise order. If polar angle of two points is same, then I need to put the nearest term first. I defined the predicate angle2d/2:
angle2d(A, B, R) :-
A =.. [_,Ax,Ay],
B =.. [_,Bx,By],
R is atan2((Ay-By),(Ax-Bx)).
that give me the counter clockwise angle between 2 points, but i didn't get how to create the predicate sort_list/2 that will sort my n-1 points (the first one element of the list will remain unchanged) by their counter clockwise angle with the first element (point) of the list.