@tscircuit/math-utils 0.0.27 → 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
+ // src/normalize-degrees.ts
2
+ function normalizeDegrees(angle) {
3
+ const normalized = (angle % 360 + 360) % 360;
4
+ return normalized;
5
+ }
6
+
7
+ export {
8
+ normalizeDegrees
9
+ };
10
+ //# sourceMappingURL=chunk-P6GW5PWY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/normalize-degrees.ts"],"sourcesContent":["export function normalizeDegrees(angle: number): number {\n const normalized = ((angle % 360) + 360) % 360\n return normalized\n}\n"],"mappings":";AAAO,SAAS,iBAAiB,OAAuB;AACtD,QAAM,cAAe,QAAQ,MAAO,OAAO;AAC3C,SAAO;AACT;","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
@@ -12,3 +12,5 @@ export { boundsAreaOverlap } from './bounds-area-overlap.js';
12
12
  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
+ export { normalizeDegrees } from './normalize-degrees.js';
16
+ export { getBoundsFromPoints } from './get-bounds-from-points.js';
package/dist/index.js CHANGED
@@ -1,20 +1,3 @@
1
- import {
2
- distSq,
3
- midpoint,
4
- pointToBoundsDistance,
5
- pointToBoxDistance
6
- } from "./chunk-BLY7FZPX.js";
7
- import "./chunk-MTORG67J.js";
8
- import {
9
- areBoundsCompletelyInsidePolygon,
10
- areBoundsOverlappingPolygon,
11
- isPointInsidePolygon,
12
- isRectCompletelyInsidePolygon,
13
- isRectOverlappingPolygon
14
- } from "./chunk-RCZE5Q5V.js";
15
- import {
16
- range
17
- } from "./chunk-KY53E6CT.js";
18
1
  import {
19
2
  pointToSegmentClosestPoint,
20
3
  segmentToBoundsMinDistance,
@@ -22,6 +5,15 @@ import {
22
5
  segmentToCircleMinDistance,
23
6
  segmentToSegmentMinDistance
24
7
  } from "./chunk-6PD3WN3Y.js";
8
+ import {
9
+ normalizeDegrees
10
+ } from "./chunk-P6GW5PWY.js";
11
+ import {
12
+ distSq,
13
+ midpoint,
14
+ pointToBoundsDistance,
15
+ pointToBoxDistance
16
+ } from "./chunk-BLY7FZPX.js";
25
17
  import {
26
18
  clamp,
27
19
  computeDistanceBetweenBoxes,
@@ -30,6 +22,14 @@ import {
30
22
  findNearestPointsBetweenBoxSets,
31
23
  getBoundingBox
32
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";
33
33
  import {
34
34
  distance,
35
35
  doSegmentsIntersect,
@@ -40,6 +40,9 @@ import {
40
40
  orientation,
41
41
  pointToSegmentDistance
42
42
  } from "./chunk-EFLPMB4J.js";
43
+ import {
44
+ range
45
+ } from "./chunk-KY53E6CT.js";
43
46
  import {
44
47
  boundsAreaOverlap
45
48
  } from "./chunk-YA3GC5BB.js";
@@ -53,6 +56,9 @@ import {
53
56
  doBoundsOverlap
54
57
  } from "./chunk-CA5ORSO4.js";
55
58
  import "./chunk-GYQ2KZV6.js";
59
+ import {
60
+ getBoundsFromPoints
61
+ } from "./chunk-5N7UJNVK.js";
56
62
  import {
57
63
  getUnitVectorFromDirection,
58
64
  getUnitVectorFromPointAToB
@@ -78,6 +84,7 @@ export {
78
84
  doesSegmentIntersectRect,
79
85
  findNearestPointsBetweenBoxSets,
80
86
  getBoundingBox,
87
+ getBoundsFromPoints,
81
88
  getSegmentIntersection,
82
89
  getUnitVectorFromDirection,
83
90
  getUnitVectorFromPointAToB,
@@ -86,6 +93,7 @@ export {
86
93
  isRectCompletelyInsidePolygon,
87
94
  isRectOverlappingPolygon,
88
95
  midpoint,
96
+ normalizeDegrees,
89
97
  onSegment,
90
98
  orientation,
91
99
  pointToBoundsDistance,
@@ -0,0 +1,3 @@
1
+ declare function normalizeDegrees(angle: number): number;
2
+
3
+ export { normalizeDegrees };
@@ -0,0 +1,7 @@
1
+ import {
2
+ normalizeDegrees
3
+ } from "./chunk-P6GW5PWY.js";
4
+ export {
5
+ normalizeDegrees
6
+ };
7
+ //# sourceMappingURL=normalize-degrees.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.27",
4
+ "version": "0.0.29",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",