10 lines
273 B
TypeScript
10 lines
273 B
TypeScript
|
import convexHull from 'monotone-convex-hull-2d'
|
||
|
import type { Point } from '../common/Vector2'
|
||
|
|
||
|
export function ConvexHull2D(points: Point[]): Point[]
|
||
|
{
|
||
|
let pts = points.map(p => [p.x, p.y])
|
||
|
let indexs: number[] = convexHull(pts)
|
||
|
return indexs.map(i => points[i])
|
||
|
}
|