Computing nearest point in a cone of angle

99 Views Asked by At

Figure 1 enter image description here

In the above figure, there are 3 agents namely i_1, i_2 and i_3. For each agent, I know the velocity (v_x, v_y) and the position (x,y).

I wish to compute the nearest agent within the cone of vision say x degrees of an agent. (Cone of vision depicted above for i_1)

In above figure, considering the i_1: the computation should result in i_2.

My naive approach is to first calculate i_1's direction taking tan(vx/xy). Now compute a line in direction with i_1's coordinates. Then rotating the line 22.5 right and 22.5 left. Now iterate from left to right with step size=~0.01 degrees and compute the intersection at each direction with distance from agent. Store the agent with least distance.

But this is highly inefficient. I would appreciate better approaches.

I asked the same question at stackoverflow but got no response. Therefore, thought about asking here.

1

There are 1 best solutions below

0
On

I would draw a sphere two times the distance from i1 to i3 or i2 if you only want to work on i2. I don't know what type of software you may have to look at this in 3d instead of 2d. But you could place the cone within the sphere. To only track within the cone. It is easier to track in a sphere than a cone for locations. Then draw the cone in the sphere. To check on problems or locations. Have the software give warnings for cone locations.