I get the positions of 5 enemies in the game in vectors. Depending on the distance I choose, the number of enemies can vary from 0 to 5. I need to know their vectors each time to check whether it is possible to draw a straight line through a certain number of heroes (vectors).
After that, my hero will have to use his ability called wall. It consists of 2 start and end vectors. Thus, check whether my hero can put a wall on the enemies in the line to catch them
Let's say there are 3 enemy heroes whose positions I can get. I need to find out if I can pass through them directly, in order to use the ability on them.
Here's what using the ability looks like in the game
Here is getting the vector of one of the heroes

The ability itself can be twisted at a certain point. But anyway, it is necessary that the wall would touch several heroes

Wherever I move the mouse, I can put it in the desired position. But unfortunately it takes a lot of time, so I would like to automate

The coordinates of the wall itself, or rather its two edges, I can also get, but only after the ability has been used



Any line in the plane can be described by an equation
a*x + b*y + c = 0with(a, b) ≠ (0, 0). Note that if you have an equation of this form, then multiplying each coefficienta, b, cwith the same number yields an equation describing the same line. That's the reason(a, b, c)is called a homogeneous coordinate vector for that line.How do you find
a, b, c? One simple approach would be treating this as three linear equations in three unknowns. You plug in thexandycoordinates for all your three points, and get tree equations forathoroughc. However, there is a catch. Since the right hand side of each equation is zero,a = b = c = 0is always a solution. In those cases where there is only one solution, that will be it. So in order for there to be a line, you need more than one solution. The mathematical tool to determine whether a set of equations had more than one solution is the determinant. It is zero if the system has no single unique solution.Long story short: three points are collinear (on a line) if
The homogeneous coordinate vector describing the line world correspond to the kernel of that matrix.
Of course, if your input coordinates are floating point numbers, exact zero is unlikely. Presumably that wall does allow for some error in some way, and you'd need to tell us about that in order to get an answer that models this aspect correctly. In the mean time, know that the absolute value of the determinant above is proportional to the area of the triangle created by these three points. So if your were to pick a constant threshold value, the farther your enemies are apart along the direction of the wall, the less they could deviate from the straight line without violating that threshold.