gx
chenyc
2025-06-12 7b72ac13a83764a662159d4a49b7fffb90476ecb
1
2
3
4
5
6
7
8
9
10
11
12
import { BoundingBox, IPoint } from '../classes/index';
 
export function minBbox(pts: IPoint[]): BoundingBox {
  const xs = pts.map((pt) => pt.x);
  const ys = pts.map((pt) => pt.y);
  const minX = xs.reduce((min, x) => (x < min ? x : min), Infinity);
  const minY = ys.reduce((min, y) => (y < min ? y : min), Infinity);
  const maxX = xs.reduce((max, x) => (max < x ? x : max), 0);
  const maxY = ys.reduce((max, y) => (max < y ? y : max), 0);
 
  return new BoundingBox(minX, minY, maxX, maxY);
}