@tscircuit/math-utils 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ // src/get-bounds-from-points.ts
2
+ var getBoundsFromPoints = (points) => {
3
+ if (points.length === 0) {
4
+ return null;
5
+ }
6
+ let minX = points[0].x;
7
+ let minY = points[0].y;
8
+ let maxX = points[0].x;
9
+ let maxY = points[0].y;
10
+ for (let i = 1; i < points.length; i++) {
11
+ const point = points[i];
12
+ if (point.x < minX) minX = point.x;
13
+ if (point.y < minY) minY = point.y;
14
+ if (point.x > maxX) maxX = point.x;
15
+ if (point.y > maxY) maxY = point.y;
16
+ }
17
+ return { minX, minY, maxX, maxY };
18
+ };
19
+
20
+ export {
21
+ getBoundsFromPoints
22
+ };
23
+ //# sourceMappingURL=chunk-5N7UJNVK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-bounds-from-points.ts"],"sourcesContent":["import type { Bounds, Point } from \"./common\"\n\n/**\n * Calculates the bounding rectangle from an array of points\n * @param points Array of points to calculate bounds from\n * @returns Bounds object containing minX, minY, maxX, maxY, or null if array is empty\n */\nexport const getBoundsFromPoints = (points: Point[]): Bounds | null => {\n if (points.length === 0) {\n return null\n }\n\n let minX = points[0].x\n let minY = points[0].y\n let maxX = points[0].x\n let maxY = points[0].y\n\n for (let i = 1; i < points.length; i++) {\n const point = points[i]\n if (point.x < minX) minX = point.x\n if (point.y < minY) minY = point.y\n if (point.x > maxX) maxX = point.x\n if (point.y > maxY) maxY = point.y\n }\n\n return { minX, minY, maxX, maxY }\n}\n"],"mappings":";AAOO,IAAM,sBAAsB,CAAC,WAAmC;AACrE,MAAI,OAAO,WAAW,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,OAAO,CAAC,EAAE;AACrB,MAAI,OAAO,OAAO,CAAC,EAAE;AACrB,MAAI,OAAO,OAAO,CAAC,EAAE;AACrB,MAAI,OAAO,OAAO,CAAC,EAAE;AAErB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;AACtC,UAAM,QAAQ,OAAO,CAAC;AACtB,QAAI,MAAM,IAAI,KAAM,QAAO,MAAM;AACjC,QAAI,MAAM,IAAI,KAAM,QAAO,MAAM;AACjC,QAAI,MAAM,IAAI,KAAM,QAAO,MAAM;AACjC,QAAI,MAAM,IAAI,KAAM,QAAO,MAAM;AAAA,EACnC;AAEA,SAAO,EAAE,MAAM,MAAM,MAAM,KAAK;AAClC;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { Point, Bounds } from './common.js';
2
+
3
+ /**
4
+ * Calculates the bounding rectangle from an array of points
5
+ * @param points Array of points to calculate bounds from
6
+ * @returns Bounds object containing minX, minY, maxX, maxY, or null if array is empty
7
+ */
8
+ declare const getBoundsFromPoints: (points: Point[]) => Bounds | null;
9
+
10
+ export { getBoundsFromPoints };
@@ -0,0 +1,7 @@
1
+ import {
2
+ getBoundsFromPoints
3
+ } from "./chunk-5N7UJNVK.js";
4
+ export {
5
+ getBoundsFromPoints
6
+ };
7
+ //# sourceMappingURL=get-bounds-from-points.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export { boundsDistance } from './bounds-distance.js';
13
13
  export { boundsIntersection } from './bounds-intersection.js';
14
14
  export { Polygon, areBoundsCompletelyInsidePolygon, areBoundsOverlappingPolygon, isPointInsidePolygon, isRectCompletelyInsidePolygon, isRectOverlappingPolygon } from './polygon.js';
15
15
  export { normalizeDegrees } from './normalize-degrees.js';
16
+ export { getBoundsFromPoints } from './get-bounds-from-points.js';
package/dist/index.js CHANGED
@@ -1,3 +1,10 @@
1
+ import {
2
+ pointToSegmentClosestPoint,
3
+ segmentToBoundsMinDistance,
4
+ segmentToBoxMinDistance,
5
+ segmentToCircleMinDistance,
6
+ segmentToSegmentMinDistance
7
+ } from "./chunk-6PD3WN3Y.js";
1
8
  import {
2
9
  normalizeDegrees
3
10
  } from "./chunk-P6GW5PWY.js";
@@ -7,24 +14,6 @@ import {
7
14
  pointToBoundsDistance,
8
15
  pointToBoxDistance
9
16
  } from "./chunk-BLY7FZPX.js";
10
- import "./chunk-MTORG67J.js";
11
- import {
12
- areBoundsCompletelyInsidePolygon,
13
- areBoundsOverlappingPolygon,
14
- isPointInsidePolygon,
15
- isRectCompletelyInsidePolygon,
16
- isRectOverlappingPolygon
17
- } from "./chunk-RCZE5Q5V.js";
18
- import {
19
- range
20
- } from "./chunk-KY53E6CT.js";
21
- import {
22
- pointToSegmentClosestPoint,
23
- segmentToBoundsMinDistance,
24
- segmentToBoxMinDistance,
25
- segmentToCircleMinDistance,
26
- segmentToSegmentMinDistance
27
- } from "./chunk-6PD3WN3Y.js";
28
17
  import {
29
18
  clamp,
30
19
  computeDistanceBetweenBoxes,
@@ -33,6 +22,14 @@ import {
33
22
  findNearestPointsBetweenBoxSets,
34
23
  getBoundingBox
35
24
  } from "./chunk-DRDDWFOS.js";
25
+ import "./chunk-MTORG67J.js";
26
+ import {
27
+ areBoundsCompletelyInsidePolygon,
28
+ areBoundsOverlappingPolygon,
29
+ isPointInsidePolygon,
30
+ isRectCompletelyInsidePolygon,
31
+ isRectOverlappingPolygon
32
+ } from "./chunk-RCZE5Q5V.js";
36
33
  import {
37
34
  distance,
38
35
  doSegmentsIntersect,
@@ -43,6 +40,9 @@ import {
43
40
  orientation,
44
41
  pointToSegmentDistance
45
42
  } from "./chunk-EFLPMB4J.js";
43
+ import {
44
+ range
45
+ } from "./chunk-KY53E6CT.js";
46
46
  import {
47
47
  boundsAreaOverlap
48
48
  } from "./chunk-YA3GC5BB.js";
@@ -56,6 +56,9 @@ import {
56
56
  doBoundsOverlap
57
57
  } from "./chunk-CA5ORSO4.js";
58
58
  import "./chunk-GYQ2KZV6.js";
59
+ import {
60
+ getBoundsFromPoints
61
+ } from "./chunk-5N7UJNVK.js";
59
62
  import {
60
63
  getUnitVectorFromDirection,
61
64
  getUnitVectorFromPointAToB
@@ -81,6 +84,7 @@ export {
81
84
  doesSegmentIntersectRect,
82
85
  findNearestPointsBetweenBoxSets,
83
86
  getBoundingBox,
87
+ getBoundsFromPoints,
84
88
  getSegmentIntersection,
85
89
  getUnitVectorFromDirection,
86
90
  getUnitVectorFromPointAToB,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/math-utils",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.28",
4
+ "version": "0.0.29",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",