# base/obb (vanilla.js 0.4.0)

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

회전된 바운딩 박스.

## OBB extends Object

회전된 바운딩 박스.

예제: 점 포함과 두 상자의 겹침 검사

```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): 생성.
- `contains(viewPosition)` (method, since 0.0.8): 좌표와 충돌 검출.
  - `viewPosition` Vector2: 검사할 점. (모서리와 같은 좌표계)
  - returns boolean: 점이 모서리들이 이루는 사각형 안에 있으면 참. (null 이거나 Vector2 가 아니면 거짓)
- `overlaps(other)` (method, since 0.0.8): 분리축 정리(SAT)를 이용한 다각형(OBB) 간의 충돌 검출.
  - `other` OBB: 검사할 상자.
  - returns boolean: 겹치면 참. (변이 닿기만 해도 참)
- `setEdges(edges)` (method, since 0.0.8): 모서리 목록 설정.
  - `edges` Vector2[]: 모서리 4 개. (둘레를 따라 차례로, 벡터를 복사하지 않고 그대로 담는다, 4 개가 아니면 오류를 던진다)
  - returns Vector2[]: 돌려주는 값 없음. (undefined)
- `getEdges()` (method, since 0.0.8): 모서리 목록 반환.
  - returns Vector2[]: 모서리 4 개. (내부 배열을 그대로 돌려준다)
