How to find first intersection of a ray with moving circles

前端 未结 2 674
猫巷女王i
猫巷女王i 2021-02-06 14:31

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 li

相关标签:
2条回答
  • 2021-02-06 14:58

    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.

    0 讨论(0)
  • 2021-02-06 15:01

    (Thinking out loud) You might want to use an octree or multi-resolution grid with Bresenham's algorithm to quickly eliminate a lot of checks?

    0 讨论(0)
提交回复
热议问题