Skip to content

Latest commit

 

History

History
52 lines (40 loc) · 1.58 KB

README.md

File metadata and controls

52 lines (40 loc) · 1.58 KB

min-rect

npm version npm downloads bundle JSDocs License

Description

Computes the minimum-area oriented bounding rectangle (2D) using the rotating calipers algorithm

How to use

import { MBR, Vector2 } from 'min-rect'

const points = [
  [0, 0],
  [1, 0],
  [0, 1],
  [1, 1],
].map(([x, y]) => new Vector2(x, y))

const mbr = mbr.fromPoints(points)

console.log(mbr)
/**
 * {
 *   halfSize: Vector2 { x: 0.5, y: 0.5 },
 *   center: Vector2 { x: 0.5, y: 0.5 },
 *   rotation: 0
 * }
 */

License

MIT License © 2024-PRESENT Bjorn