From a00c0aab1eb5a7a55bef8ca08115bdd722ab5699 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 16 May 2021 19:50:15 -0400 Subject: Moved the frontend directory up so that it no longer exists --- .../2d/_collisions/rectangle_line.html.content | 76 ---------------------- 1 file changed, 76 deletions(-) delete mode 100644 frontend/2d/_collisions/rectangle_line.html.content (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 deleted file mode 100644 index 310c45a..0000000 --- a/frontend/2d/_collisions/rectangle_line.html.content +++ /dev/null @@ -1,76 +0,0 @@ - - -
-

Rectangle intersection with a Line Segment

-
-

Algorithm

-

- For each line segment that your rectangle could be intersecting with, - do the following: -

    -
  1. - 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). -
  2. -
  3. - 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) -
  4. -
  5. - 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: - -
      -Vector2 getNormalToLineSegment(LineSegment* segment) {
      -    Vector2 direction = segment->end - segment->start;
      -    return *Vector2 { -direction.y, direction.x }).normalize();
      -}
      -				
      -
      -
    • -
    • - First Point of Application: Get the vector from the center of the rectangle (most like your position) to the corner which intersected. -
    • -
    • - Second Point of Application: Get vector from center of line to the corner which intersected. -
    • -
    -
  6. -
-

-
-
-

- Live Example -

-
- - - -
- -
-
-- cgit v1.2.1