General case 2D:
First let’s consider some parameters.
- The line is vertical and defined by points A and B
- The object is entirely on one side or on the other side of the line
- You have the information of some point P belonging to the object
To define the side the object is on, we reconnect the vector product between the vectors defined by and :
where:
The result of the vector product for two dimensions, can return a negative value, positive or null. If null, the P point in question is above the line. For the positive and negative case, one of them will be on one side of the line and the other case will be on the other side of the line.
In Python this product can be calculated as follows:
import numpy as np
A = np.array([1,2])
B = np.array([5,7])
P = np.array([3,4])
res = np.cross(B-A, P-A)
Exit:
array(-2)
For the specific case above, we have that point P is on the right side of the line defined by .
Specific case (vertical line)
In a simpler situation where the dividing line is vertical, there is only the need to compare the coordinated x
of objects in relation to the line.
Case the coordinated x
the chosen P point of the object is larger than the coordinate x
line, this object is on the right of the line. If it is smaller, it is on the left. If it is equal, the point is on top of the line
You already have some code written that you can show?
– Tuxpilgrim
Creating a [mcve] with images and code would help your question to be answered.
– danieltakeshi