bonk-docs/content/api/AABB.md

56 lines
1.4 KiB
Markdown

---
title: "AABB"
date: 2019-12-31T14:36:00-07:00
weight: 6
---
*AABB*, or axis-aligned bounding box, is defined by a minimum point and a maximum point. It is used for broad-phase collision detection. It represents a rectangular outline of the shape so we can quickly insert shapes into a *SpatialHash*.
## Properties
##### **public Vector2 Min**
The minimum point of the AABB.
##### **public Vector2 Max**
The maximum point of the AABB.
##### **public float Width**
The width of the AABB.
##### **public float Height**
The height of the AABB.
##### **public float Right**
The right point of the AABB.
##### **public float Left**
The left point of the AABB.
##### **public float Top**
The top point of the AABB.
##### **public float Bottom**
The bottom point of the AABB.
## Methods
##### **public static AABB FromVertices(IEnumerable<Position2D> vertices)**
Can be used to generate an AABB from an arbitrary collection of vertices. It is generally better to define a more efficient AABB generation method based on the properties of a particular shape, but this can be used for an arbitrary collection of vertices, like a polygon.
##### **public static AABB Transformed(AABB aabb, Transform2D transform)**
Efficiently transforms an AABB. Used internally by SpatialHash to quickly transform a shape's AABB.
##### **public static bool TestOverlap(AABB a, AABB b)**
Efficiently checks if two AABBs overlap.