@tscircuit/math-utils 0.0.28 → 0.0.30

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,9 @@
1
+ // src/is-point-in-bounds.ts
2
+ var isPointInBounds = (point, bounds) => {
3
+ return point.x >= bounds.minX && point.x <= bounds.maxX && point.y >= bounds.minY && point.y <= bounds.maxY;
4
+ };
5
+
6
+ export {
7
+ isPointInBounds
8
+ };
9
+ //# sourceMappingURL=chunk-TDJ6LMXM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/is-point-in-bounds.ts"],"sourcesContent":["import type { Bounds, Point } from \"./common\"\n\n/**\n * Determines if a point is inside or on the boundary of a bounds rectangle\n * @param point The point to check\n * @param bounds The bounding rectangle\n * @returns true if the point is within the bounds, false otherwise\n */\nexport const isPointInBounds = (point: Point, bounds: Bounds): boolean => {\n return (\n point.x >= bounds.minX &&\n point.x <= bounds.maxX &&\n point.y >= bounds.minY &&\n point.y <= bounds.maxY\n )\n}\n"],"mappings":";AAQO,IAAM,kBAAkB,CAAC,OAAc,WAA4B;AACxE,SACE,MAAM,KAAK,OAAO,QAClB,MAAM,KAAK,OAAO,QAClB,MAAM,KAAK,OAAO,QAClB,MAAM,KAAK,OAAO;AAEtB;","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,5 @@ 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';
17
+ export { isPointInBounds } from './is-point-in-bounds.js';
package/dist/index.js CHANGED
@@ -1,20 +1,3 @@
1
- import {
2
- normalizeDegrees
3
- } from "./chunk-P6GW5PWY.js";
4
- import {
5
- distSq,
6
- midpoint,
7
- pointToBoundsDistance,
8
- pointToBoxDistance
9
- } 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
1
  import {
19
2
  range
20
3
  } from "./chunk-KY53E6CT.js";
@@ -25,6 +8,18 @@ import {
25
8
  segmentToCircleMinDistance,
26
9
  segmentToSegmentMinDistance
27
10
  } from "./chunk-6PD3WN3Y.js";
11
+ import {
12
+ isPointInBounds
13
+ } from "./chunk-TDJ6LMXM.js";
14
+ import {
15
+ normalizeDegrees
16
+ } from "./chunk-P6GW5PWY.js";
17
+ import {
18
+ distSq,
19
+ midpoint,
20
+ pointToBoundsDistance,
21
+ pointToBoxDistance
22
+ } from "./chunk-BLY7FZPX.js";
28
23
  import {
29
24
  clamp,
30
25
  computeDistanceBetweenBoxes,
@@ -33,6 +28,14 @@ import {
33
28
  findNearestPointsBetweenBoxSets,
34
29
  getBoundingBox
35
30
  } from "./chunk-DRDDWFOS.js";
31
+ import "./chunk-MTORG67J.js";
32
+ import {
33
+ areBoundsCompletelyInsidePolygon,
34
+ areBoundsOverlappingPolygon,
35
+ isPointInsidePolygon,
36
+ isRectCompletelyInsidePolygon,
37
+ isRectOverlappingPolygon
38
+ } from "./chunk-RCZE5Q5V.js";
36
39
  import {
37
40
  distance,
38
41
  doSegmentsIntersect,
@@ -56,6 +59,9 @@ import {
56
59
  doBoundsOverlap
57
60
  } from "./chunk-CA5ORSO4.js";
58
61
  import "./chunk-GYQ2KZV6.js";
62
+ import {
63
+ getBoundsFromPoints
64
+ } from "./chunk-5N7UJNVK.js";
59
65
  import {
60
66
  getUnitVectorFromDirection,
61
67
  getUnitVectorFromPointAToB
@@ -81,10 +87,12 @@ export {
81
87
  doesSegmentIntersectRect,
82
88
  findNearestPointsBetweenBoxSets,
83
89
  getBoundingBox,
90
+ getBoundsFromPoints,
84
91
  getSegmentIntersection,
85
92
  getUnitVectorFromDirection,
86
93
  getUnitVectorFromPointAToB,
87
94
  grid,
95
+ isPointInBounds,
88
96
  isPointInsidePolygon,
89
97
  isRectCompletelyInsidePolygon,
90
98
  isRectOverlappingPolygon,
@@ -0,0 +1,11 @@
1
+ import { Point, Bounds } from './common.js';
2
+
3
+ /**
4
+ * Determines if a point is inside or on the boundary of a bounds rectangle
5
+ * @param point The point to check
6
+ * @param bounds The bounding rectangle
7
+ * @returns true if the point is within the bounds, false otherwise
8
+ */
9
+ declare const isPointInBounds: (point: Point, bounds: Bounds) => boolean;
10
+
11
+ export { isPointInBounds };
@@ -0,0 +1,7 @@
1
+ import {
2
+ isPointInBounds
3
+ } from "./chunk-TDJ6LMXM.js";
4
+ export {
5
+ isPointInBounds
6
+ };
7
+ //# sourceMappingURL=is-point-in-bounds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
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.30",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",