Given the points Source
, Destination
and Centre
, where a move has happened from Source
to Destination
first compute the vectors:
CentreSource = Source - Centre
CentreDestination = Destination - Centre
Compute the dot product of the tværvector of CentreSource
and CentreDestination
:
RorL = CentreSourceX * CentreDestinationY - CentreSourceY * CentreDestinationX
Now RorL
should be positive if the point is moving counterclockwise around the centre, negative in case of clockwise, and 0
if the move was either 0 or 180 degrees.
You can further check if the move was above or below 90 degrees by computing the dot product of CentreSource
and CentreDestination
:
AorB = CentreSourceX * CentreSourceY + CentreDestinationX * CentreDestinationY
If AorB
is positive then the move was below 90 degrees, if it is negative the move was above 90 degrees, and if it is 0 then the move was either exactly 90 degrees or it either started or ended in the point Centre
.