Skip to content

lxxorz/min-rect

Repository files navigation

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published