I have been struggling with a problem for a while and so far have not found any solution better then the naive one:
N circles are given that are moving according to a linear law. For each of the circles we have its initial (at moment 0.0) radius, initial coordinates and its radius and coordinates at moment 1.0 (end moment). We also have k rays given with coordinates of their origin and a vector along the ray. Each ray only exists at a given moment tk. I need to be able to find the first intersection of a ray with any of the circles. The expected number of k is quite large (millions or billions) as well as the expected number of circles (thousands). I need solution faster then checking all rays against all circles.
I have been searching round the internet for some time but I have found no good solution approach. Even an idea for the easier problem of the circles not moving will be appreciated.
I have the feeling that a kd-tree should be appropriate for the static case and maybe a kinetic kd-tree will solve the harder one. Still I cannot figure out how to use kd-tree even for the easier one.
You can look at this as static case in 3D with time as additional coordinate. Circle with path became frustum and ray is in a plane time=tk. If frustums are not positioned too dense than binary space partitioning (k-d tree, ...) can help.
To find all partitions crossed by ray first find partition where is origin and than traverse (in tree) by partition neighbour in ray direction. It depends on partitioning method used. It is linear in number of partitions crossed by ray.
Update: It is idea to put frustum in each partition it is touching. One frustum will be in more partitions.
This is an example in 1 dimension plus time. Everything is same, circles have starting and ending point and starting and ending radius.
1 | E /
| . /
| . /
| . /
| . /
0 | S /
t/X
Partitioning in X direction:
| E : /
| . :/
| . :
| . /:
| . / :
| S / :
X
This trapezoid will go in both partitions.
Partitioning in time direction:
| E : /
| . :/
| . :
t-------------------
| . / :
| S / :
X
Trapezoid from X left partition will go in both time partitions, while in X right partition it will go only in upper partition.
To implement it it is needed to calculate is there an intersection between line and axis plane on some plane part and if there is no intersection on which side of a plane is a line. Calculation is same in 2D case, or even in higher dimensions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With