Given the four points on the plane, A,B,X,Y , I want to determine which of the following two angles is less than ∢ABX or ∢ABY .
The angle ∢ABX defined as the angle BX when AB transferred to the open segment (-∞,0] . Intuitively, speaking ∢ABX , I mean the angle that you get when you turn left after visiting vertex B
I would prefer not to use cos or sqrt to maintain accuracy and minimize performance (the code will work in the embedded system).
In the case when A=(-1,0),B=(0,0) , I can compare the two angles ∢ABX and ∢ABY , calculating the point product of the vectors X,Y and see its sign.
What can I do in this case:
- Determine whether or not the
ABX turning right or left. - If
ABX turns left, check whether Y or A on the same side of the line on the BX segment or not. If they are ∢ABX less than ABY . - If
ABX turns right, then Y and A on the same side of BX means that ∢ABX greater than ∢ABY .
But that seems too complicated to me.
Any simpler approach?
source share