From 0ebc47873fc58645ad6b4dbef68a3571f6e67bbb Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 30 Jun 2021 19:13:11 -0400 Subject: Honestly, a much better simulation going on here --- 2d/_collisions/polygon_polygon.html.content | 43 +++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) (limited to '2d/_collisions/polygon_polygon.html.content') diff --git a/2d/_collisions/polygon_polygon.html.content b/2d/_collisions/polygon_polygon.html.content index 29c284d..4f99d71 100644 --- a/2d/_collisions/polygon_polygon.html.content +++ b/2d/_collisions/polygon_polygon.html.content @@ -115,17 +115,48 @@

SAT Collision Resolution

- 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:

-

Collision Normal

-

- -

+ 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. +
+ +

Finding the Intersecting Edge

+ We can already figure out that the following two triangles intersect one another: +
+
+ +
+ +
+ +

+ + We know that A can only intersect B if: (1) a vertex from A is inside of B, (2) an edge of A flatly intersects an edge of B, or (3) a vertex of A overlaps exactly a vertex of 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 with both polygons projected onto it: + +

+ +
+ +
+ +

+ 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: +
+
+ + The intersecting edge will be the one where the projection of triangle A overlaps with the projection of triangle B the least! + +

+ 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. +
+ +

Finding which point causes the intersection

+

-- cgit v1.2.1