comparing two angles

Posted by Elazar Leibovich on Stack Overflow See other posts from Stack Overflow or by Elazar Leibovich
Published on 2010-05-23T14:04:37Z Indexed on 2010/05/23 14:11 UTC
Read the original article Hit count: 398

Filed under:
|
|

Given four points in the plane, A,B,X,Y, I wish to determine which of the following two angles is smaller ?ABX or ?ABY.

I'd rather not use cos or sqrt, in order to preserve accuracy.

In the case where A=(-1,0),B=(0,0), I can compare the two angles ?ABX and ?ABY, by calculating the dot product of the vectors X,Y, and watch it's sign.

What I can do in this case is:

  1. Determine whether or not ABX turns right or left
  2. If ABX turns left check whether or not Y and A are on the same side of the line on segment BX. If they are - ?ABX is a smaller than ABY.
  3. If ABX turns right, then Y and A on the same side of BX means that ?ABX is larger than ?ABY.

But this seems too complicated to me.

Any simpler approach?

© Stack Overflow or respective owner

Related posts about math

Related posts about vector