I have three vectors V1, V2, and V3. Their origin points are on the axes' origin. How could I determine whether V3 is between V1 and V2 when I move around counterclockwise from V1 to V2?
alt text http://www.freeimagehosting.net/uploads/1448ea8896.jpg
It can't be done with obtaining their angles and evaluating these kind of conditions (pseudo-code):
if angle(V3) > angle(V1) && angle(V3) < angle(V2)
printf("V3 is between V1 and V2")
else
printf("out of the interval")
To see its defect, suppose that the angle
function gives angles in the range of [-pi pi]. So, if angle(V1) = 120 (in degree), angle(V2) = -130 and angle(V3) = 150 then the answer (according to the above code) is "out of the interval" although if you move around counterclockwise from V1 to V2, it is between them.
You may suggest adding 2*pi to angle(V2) or something like that, but I've tried such things and it doesn't work.
I'm programming in MATLAB.
EDIT 1 : it is in 2D.