Note that there are some explanatory texts on larger screens.

plurals
  1. POAABB outline to AABB outline intersection points algorithm?
    primarykey
    data
    text
    <p>I've looked around but haven't exactly found what I'm looking for. At first, I thought this would be a simple problem.. Until I tried to implement it and realized there were many cases and I could not find a generic solution.</p> <p>Say, I have two AABBs. If their outlines intersect, I want to get all their points of intersection. The <strong>maximum</strong> amount of points is <strong>4</strong>, the <strong>minimum non-zero</strong> amount of points is <strong>1</strong>.</p> <p>My AABBs are composed of a <code>min</code> and <code>max</code> point that are always automatically sorted so that <code>min</code> always has the <strong>lowest</strong> x-y values and <code>max</code> always has the <strong>highest</strong> x-y values.</p> <p>The image below shows a few AABBs. The blue lines indicate their points of intersection. Note that if a side of an AABB overlaps another side, it's kind of like having an infinite amount of intersection points along the line-segments that overlap; in those cases, I want to ignore them and say, "There are no intersection points there".</p> <p>Anyone got an idea for an algorithm? I realize I haven't posted any code and I'm pretty sure that's frowned upon but I have thought about this problem quite a bit. As for <strong>why</strong> I want to do this.. I duno', I'm just curious as to whether it's possible to do this cleanly.</p> <p>Oh, yeah, my AABBs have methods like these that should be useful:</p> <pre><code>Vector&lt;2&gt; getSize () const; Point&lt;2&gt; getCenter () const; //0=Quadrant-1, 1=Quadrant-2, 2=Quadrant-3, 3=Quadrant-4, else, error Point&lt;2&gt; getCorner (int index) const; //0=right, 1=up, 2=left, 3=down, else, error LineSegment2D getSide (int index) const; </code></pre> <p>I could do an ugly hack and just do line-segment &lt;-> line-segment checks but, I duno'.. It feels kinda', well, ugly and inelegant. I'm pretty sure there must be some trickery I could do with the <code>min</code> and <code>max</code> points to do this quickly.</p> <p><img src="https://dl.dropboxusercontent.com/u/86400999/aabbaabbintersection.png" alt="Example"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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