Categorize circle on a plane with "left" and "right" relative to a line. CONTEXT:
I'm doing a simulation in Object Oriented Programming. I have a bunch of circles with properties:
Location = Vector with x and y coordinate
Angle = Vector détermining "where" the circle is looking at
DetectionRadius = A bigger circle, we want to interact only with others circle located within that circle.
So i have my central circle and secondary circle all around the plane. I have access to all circle properties in an array. My question is:
PROBLEM:
How can i determine wich circle is on the left side of my central circle, and wich are on the right side ?
Here is an image to understand better what i mean: Image1
(Principal circle is in the center, black line is the angle vector (we can extend it to a line if needed), blue circle is the detection radius and other green circle are secondary circles)
I already know wich secondary circle are in the principal circle's detection radius. I just need to know wich are on the left, wich are on the right.
Thank you !
 A: Form the equation of the line. Then the question on which side of the line a point is can be answered by calculating the value of the defining (linear) function of the line. On the line its value will be $0$. The value is positive/negative if the point is on the left/right (when looking to the direction of the vector defining the line).
In this case we get the equation of the line as (notice the coefficients make a 90 deg rotation of the given direction vector, since to be on the line means the inner product with its normal vector be zero, we also need a translation from the point $C$ to the origin in there)
$$l(x,y) = -\sin(\alpha) (x-c_x) + \cos (\alpha) (y-c_y)$$
where $\alpha$ is the angle and $(c_x, c_y)$ is the center of the central circle. Try it out here.
A: If you take the "viewpoint" vector $\vec v$ and construct a unit-length vector orthogonal to this, you can take the (relative) vector position of the centres of the other circles $\{\vec c_i\}$ and get not only whether they are left or right of the line, but whether they cut the line of sight.
To get an anticlockwise (left-turned) orthogonal vector, you simply need to switch $\vec v=(x,y)$ coordinates of the viewpoint vector to $\vec v^\perp=(-y, x)$. Divide both ordinates by the magnitude $|\vec v|$ to get your unit test vector $\vec t = \frac{\vec v^\perp}{|v|}$.
Then take the dot product of each circle vector to be assessed to get a corresponding set of (scalar) values $\{\vec t\cdot \vec c_i\}$. Dot product is efficient to calculate: $(a,b)\cdot(c,d) = ac+bd$. A positive value means that circle $i$ is to the left; a negative value is to the right, and the absolute value gives you how far away from the line it is - so comparing to the secondary circle radius will tell you if it cuts the line.

