From cdf770d6950befd25779a18ea3972deeb9f143bb Mon Sep 17 00:00:00 2001
From: Matthew Kosarek
Date: Sun, 25 Apr 2021 15:33:53 -0400
Subject: Rectangle intersection with a line complete
---
.../2d/_collisions/rectangle_line.html.content | 114 ++++++++++++++-------
1 file changed, 76 insertions(+), 38 deletions(-)
(limited to 'frontend/2d/_collisions/rectangle_line.html.content')
diff --git a/frontend/2d/_collisions/rectangle_line.html.content b/frontend/2d/_collisions/rectangle_line.html.content
index 9f008a4..310c45a 100644
--- a/frontend/2d/_collisions/rectangle_line.html.content
+++ b/frontend/2d/_collisions/rectangle_line.html.content
@@ -1,38 +1,76 @@
-
-
-
-
Rectangle-Line
-
-
- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
-
-
-
-
-
-
-
-
-
+
+
+
+
Rectangle intersection with a Line Segment
+
+
Algorithm
+
+ For each line segment that your rectangle could be intersecting with,
+ do the following:
+
+
+ For each corner of your rectangle, check if the distance from that point to the line is less than some epsilon, where epsilon is a reasonable small number (usually a 1 or 2 units, depending on the size of your lines).
+
+
+ To check each point, use the "distance from point to line segment" formula, which can be found here (I will not derive it just yet)
+
+
+ If a collision is found, we have all of the information required to solve the collision:
+
+
+ Collision Normal: This is the perpendicular to the line segment, which can be found by:
+
+