Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I doubt there is better solution than calculating the distance between the red one and every blue one and sorting these by length.</p> <p>Regarding sorting, usually QuickSort is hard to beat in performance (an optimized one, that cuts off recursion if size goes below 7 items and switches to something like InsertionSort, maybe ShellSort).</p> <p>Thus I guess the question is how to quickly calculate the distance between two polygons, after all you need to make this computation 50 times.</p> <p>The following approach will work for 3D as well, but is probably not the fastest one:</p> <p><a href="http://cgm.cs.mcgill.ca/~orm/mind2p.html" rel="noreferrer">Minimum Polygon Distance in 2D Space</a></p> <p>The question is, are you willing to trade accuracy for speed? E.g. you can pack all polygons into bounding boxes, where the sides of the boxes are parallel to the coordinate system axes. 3D games use this approach pretty often. Therefor you need to find the maximum and minimum values for every coordinate (x, y, z) to construct the virtual bounding box. Calculating the distances of these bounding boxes is then a pretty trivial task.</p> <p>Here's an example image of more advanced bounding boxes, that are not parallel to the coordinate system axes:</p> <p><a href="http://xna-uk.net/photos/screen_shots/images/1291/original.aspx" rel="noreferrer">Oriented Bounding Boxes - OBB</a></p> <p>However, this makes the distance calculation less trivial. It is used for collision detection, as you don't need to know the distance for that, you only need to know if one edge of one bounding box lies within another bounding box.</p> <p>The following image shows an axes aligned bounding box:</p> <p><a href="http://www.gamasutra.com/features/20000330/bobic_05.gif" rel="noreferrer">Axes Aligned Bounding Box - AABB</a></p> <p>OOBs are more accurate, AABBs are faster. Maybe you'd like to read this article:</p> <p><a href="http://www.gamasutra.com/features/20000330/bobic_pfv.htm" rel="noreferrer">Advanced Collision Detection Techniques</a></p> <p>This is always assuming, that you are willing to trade precision for speed. If precision is more important than speed, you may need a more advanced technique.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload