I have a three points (A,B,C) that denote objects moving in 2D space. For each node I know its position and its velocity vector. All three objects are moving in the same direction.
I would like to know whether a point C (x3, y3) approximates a “positive” extension to the line formed by points A(x1, y1) and B(x2, y2). That is, I would like to know whether point C is “ahead” of point B (i.e “A->B->C” and not “C->A->B”).
I know that checking if points A, B, C are collinear will give me an indication of all three points are lying on the same line, however, i cannot figure out whether point C approximates a positive extension to the line.
Any suggestion would be highly appreciated.
You can calculate the scalar product of the difference vectors AB and BC. If that is positive, then C is what you call ‘in front of B. It may be way off to the left or right, though.
The scalar product would be calculated as
when A=(a1, a2), B=(b1, b2), C= (c1,c2) – it is the cos of the angle between the two vectors times the lengths of the vectors, and cos is positive for angles less than 90 degree.