summaryrefslogtreecommitdiff
path: root/2d/_collisions/polygon_polygon.html
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-06-30 19:13:11 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-06-30 19:13:11 -0400
commit0ebc47873fc58645ad6b4dbef68a3571f6e67bbb (patch)
tree4ce6976734ae55f209581c27dba6897345584317 /2d/_collisions/polygon_polygon.html
parent52d43a63d02e973f28aa30b768eddc042a4f155b (diff)
Honestly, a much better simulation going on here
Diffstat (limited to '2d/_collisions/polygon_polygon.html')
-rw-r--r--2d/_collisions/polygon_polygon.html39
1 files changed, 33 insertions, 6 deletions
diff --git a/2d/_collisions/polygon_polygon.html b/2d/_collisions/polygon_polygon.html
index 4c4698a..2e22f49 100644
--- a/2d/_collisions/polygon_polygon.html
+++ b/2d/_collisions/polygon_polygon.html
@@ -217,17 +217,44 @@
<section>
<h2>SAT Collision Resolution</h2>
<p>
- Now that we know our objects have intersected, we want to be able to send them tumbling away from each other to simulate a collision. To do this, we will need to find the following things:
+ Now that we know that our objects have intersected, we want to send them tumbling away from one another in order to simulate a collision. To do this, we will need to find the following things:
<ul>
- <li><b>Collision Normal</b>: in what direction, point towards object <b>A</b>, did the polygons intersect</li>
<li><b>Point of Application</b>: at what point on each object did the objects first intersect</li>
+ <li><b>Collision Normal</b>: in what direction, point towards object <b>A</b>, did the polygons intersect</li>
<li><b>Relative Velocity</b>: easily found by taking the difference between the two velocities.
</ul>
- <h3>Collision Normal</h3>
- <p>
-
- </p>
+ To find these values, we must first find both the shape and the edge that caused the intersection in the first place. To do this, we will think about what we know so far and try to arrive at some intutitive understanding of it. Keep in mind that I am not a proof-minded person, so you will not be finding that here.
+ <br/>
+
+ <h3>Finding the Intersecting Edge</h3>
+ We can already figure out that the following two triangles intersect one another:
+ <br />
+ <br />
+
+ <div class='image'>
+ <img src='polygon_polygon/images/3a.png' />
+ </div>
+
+ <br/><br/>
+
+ We know that <b>A</b> can only intersect <b>B</b> if: (1) a vertex from <b>A</b> is inside of <b>B</b>, (2) an edge of <b>A</b> flatly intersects an edge of <b>B</b>, or (3) a vertex of <b>A</b> overlaps exactly a vertex of <b>B</b>. Honestly, for our purposes, scenarios 2 and 3 are quite unlikely, but we can explore them a bit just to see how we might resolve them. We will start with the first case, since it is more likely. We will start by drawing the axis defined by the leftmost edge of <b>B</b> with both polygons projected onto it:
+
+ <br /> <br />
+
+ <div class='image'>
+ <img src='polygon_polygon/images/3c.png' />
+ </div>
+
+ <br/><br/>
+ This is a poorly drawn picture, but you should be able to see that the bit in green represents the intersection between the projections of the two polygons. If we were to repeat this same exercise for every edge here, we'll begin to see something very interesting. And, if we take new shapes and continue this stategy, we can begin to come to a very elegant conclusion:
+ <br/>
+ <br/>
+
+ <i>The intersecting edge will be the one where the projection of triangle <b>A</b> overlaps with the projection of triangle <b>B</b> the <b>least</b></i>!
+
+ <br /> <br />
+ I'm sure someone more inclined to proving mathematical truities would love to describe this to you, but, for all intents and purposes, this intutitive understanding is good enough for us. We just want to make games, anyhow.
</p>
</section>
<section>