# base/obb (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/base/obb/

Rotated bounding box.

## OBB extends Object

Rotated bounding box.

Example: Test point containment and overlap of two boxes

```js
import { OBB, Vector2 } from "./build/vanilla.js";

const box = new OBB();
box.setEdges([Vector2.create(0, 0), Vector2.create(10, 0), Vector2.create(10, 10), Vector2.create(0, 10)]);
const diamond = new OBB();
diamond.setEdges([Vector2.create(15, 5), Vector2.create(20, 10), Vector2.create(15, 15), Vector2.create(8, 10)]);
const point = Vector2.create(5, 5);
console.log(box.contains(point), box.overlaps(diamond));
```

- `constructor()` (constructor, since 0.0.8): Constructor.
- `contains(viewPosition)` (method, since 0.0.8): Collision detection with a point.
  - `viewPosition` Vector2: Point to test. (in the same coordinate space as the corners)
  - returns boolean: True if the point is inside the quadrilateral formed by the corners. (false if null or not a Vector2)
- `overlaps(other)` (method, since 0.0.8): Collision detection between polygons (OBB) using the separating axis theorem (SAT).
  - `other` OBB: Box to test.
  - returns boolean: True if they overlap. (also true if the edges only touch)
- `setEdges(edges)` (method, since 0.0.8): Sets the corner list.
  - `edges` Vector2[]: The 4 corners. (in order around the perimeter, stored as is without copying, throws an error if not 4)
  - returns Vector2[]: Returns nothing. (undefined)
- `getEdges()` (method, since 0.0.8): Returns the corner list.
  - returns Vector2[]: The 4 corners. (returns the internal array as is)
