jakke-graphics-ts
    Preparing search index...

    Function hasBoundingBoxCollision2d

    • Determines whether two 2D bounding boxes collide using the Separating Axis Theorem (SAT).

      The function projects both bounding boxes onto four axes (the local axes of each box) and checks for overlap in each projection. If the projections overlap on all axes, the boxes are colliding. Optionally, touching (contacting) boxes can be considered as colliding.

      Parameters

      • boxA: BoundingBox2d

        The first bounding box to test for collision.

      • boxB: BoundingBox2d

        The second bounding box to test for collision.

      • includeContating: boolean = false

        If true, boxes that are merely touching are considered colliding; otherwise, only overlapping boxes are considered colliding. Defaults to false.

      Returns ActionResult<SATSections>

      An ActionResult containing a boolean indicating collision, an array of SAT section results, and error information if applicable.

      • Returns an error if either bounding box has a zero-length axis.
      • Uses a tolerance value to handle floating-point imprecision when checking for separation.
      • The returned args array contains the projected sections for each axis.