@tscircuit/math-utils 0.0.32 → 0.0.34

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,10 @@
1
+ // src/get-bounds-center.ts
2
+ var getBoundsCenter = (bounds) => ({
3
+ x: (bounds.minX + bounds.maxX) / 2,
4
+ y: (bounds.minY + bounds.maxY) / 2
5
+ });
6
+
7
+ export {
8
+ getBoundsCenter
9
+ };
10
+ //# sourceMappingURL=chunk-3WCUPG5S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-bounds-center.ts"],"sourcesContent":["import type { Bounds, Point } from \"./common\"\n\n/**\n * Calculates the center point of a bounds rectangle.\n * @param bounds Bounds object containing minX, minY, maxX, maxY\n * @returns Center point of the bounds\n */\nexport const getBoundsCenter = (bounds: Bounds): Point => ({\n x: (bounds.minX + bounds.maxX) / 2,\n y: (bounds.minY + bounds.maxY) / 2,\n})\n"],"mappings":";AAOO,IAAM,kBAAkB,CAAC,YAA2B;AAAA,EACzD,IAAI,OAAO,OAAO,OAAO,QAAQ;AAAA,EACjC,IAAI,OAAO,OAAO,OAAO,QAAQ;AACnC;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- clamp
3
- } from "./chunk-DRDDWFOS.js";
4
1
  import {
5
2
  distance
6
3
  } from "./chunk-EFLPMB4J.js";
4
+ import {
5
+ clamp
6
+ } from "./chunk-DRDDWFOS.js";
7
7
 
8
8
  // src/point-distance.ts
9
9
  function pointToBoxDistance(p, box) {
@@ -46,4 +46,4 @@ export {
46
46
  midpoint,
47
47
  distSq
48
48
  };
49
- //# sourceMappingURL=chunk-BLY7FZPX.js.map
49
+ //# sourceMappingURL=chunk-5J3PCV4D.js.map
@@ -1,11 +1,11 @@
1
- import {
2
- clamp
3
- } from "./chunk-DRDDWFOS.js";
4
1
  import {
5
2
  distance,
6
3
  doSegmentsIntersect,
7
4
  pointToSegmentDistance
8
5
  } from "./chunk-EFLPMB4J.js";
6
+ import {
7
+ clamp
8
+ } from "./chunk-DRDDWFOS.js";
9
9
 
10
10
  // src/segment-distance.ts
11
11
  function segmentToSegmentMinDistance(a, b, u, v) {
@@ -109,4 +109,4 @@ export {
109
109
  segmentToCircleMinDistance,
110
110
  pointToSegmentClosestPoint
111
111
  };
112
- //# sourceMappingURL=chunk-6PD3WN3Y.js.map
112
+ //# sourceMappingURL=chunk-Y7G4VXR7.js.map
@@ -0,0 +1,14 @@
1
+ import { Point, Bounds } from './common.js';
2
+
3
+ /**
4
+ * Calculates the bounds of a rectangle given its center point, width, and height.
5
+ * @param params Object containing center point (x, y), width, and height of the rectangle
6
+ * @returns Bounds object containing minX, minY, maxX, maxY
7
+ */
8
+ declare const getBoundFromCenteredRect: (params: {
9
+ center: Point;
10
+ width: number;
11
+ height: number;
12
+ }) => Bounds;
13
+
14
+ export { getBoundFromCenteredRect };
@@ -0,0 +1,16 @@
1
+ // src/get-bound-from-centered-rect.ts
2
+ var getBoundFromCenteredRect = (params) => {
3
+ const { center, width, height } = params;
4
+ const halfWidth = width / 2;
5
+ const halfHeight = height / 2;
6
+ return {
7
+ minX: center.x - halfWidth,
8
+ maxX: center.x + halfWidth,
9
+ minY: center.y - halfHeight,
10
+ maxY: center.y + halfHeight
11
+ };
12
+ };
13
+ export {
14
+ getBoundFromCenteredRect
15
+ };
16
+ //# sourceMappingURL=get-bound-from-centered-rect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/get-bound-from-centered-rect.ts"],"sourcesContent":["import type { Bounds, Point } from \"./common\"\n\n/**\n * Calculates the bounds of a rectangle given its center point, width, and height.\n * @param params Object containing center point (x, y), width, and height of the rectangle\n * @returns Bounds object containing minX, minY, maxX, maxY\n */\nexport const getBoundFromCenteredRect = (params: {\n center: Point\n width: number\n height: number\n}): Bounds => {\n const { center, width, height } = params\n const halfWidth = width / 2\n const halfHeight = height / 2\n\n return {\n minX: center.x - halfWidth,\n maxX: center.x + halfWidth,\n minY: center.y - halfHeight,\n maxY: center.y + halfHeight,\n }\n}\n"],"mappings":";AAOO,IAAM,2BAA2B,CAAC,WAI3B;AACZ,QAAM,EAAE,QAAQ,OAAO,OAAO,IAAI;AAClC,QAAM,YAAY,QAAQ;AAC1B,QAAM,aAAa,SAAS;AAE5B,SAAO;AAAA,IACL,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,IACjB,MAAM,OAAO,IAAI;AAAA,EACnB;AACF;","names":[]}
@@ -0,0 +1,10 @@
1
+ import { Bounds, Point } from './common.js';
2
+
3
+ /**
4
+ * Calculates the center point of a bounds rectangle.
5
+ * @param bounds Bounds object containing minX, minY, maxX, maxY
6
+ * @returns Center point of the bounds
7
+ */
8
+ declare const getBoundsCenter: (bounds: Bounds) => Point;
9
+
10
+ export { getBoundsCenter };
@@ -0,0 +1,7 @@
1
+ import {
2
+ getBoundsCenter
3
+ } from "./chunk-3WCUPG5S.js";
4
+ export {
5
+ getBoundsCenter
6
+ };
7
+ //# sourceMappingURL=get-bounds-center.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -14,3 +14,4 @@ export { boundsIntersection } from './bounds-intersection.js';
14
14
  export { Polygon, areBoundsCompletelyInsidePolygon, areBoundsOverlappingPolygon, isPointInsideBounds, isPointInsidePolygon, isRectCompletelyInsidePolygon, isRectOverlappingPolygon } from './polygon.js';
15
15
  export { normalizeDegrees } from './normalize-degrees.js';
16
16
  export { getBoundsFromPoints } from './get-bounds-from-points.js';
17
+ export { getBoundsCenter } from './get-bounds-center.js';
package/dist/index.js CHANGED
@@ -1,10 +1,28 @@
1
+ import {
2
+ areBoundsCompletelyInsidePolygon,
3
+ areBoundsOverlappingPolygon,
4
+ isPointInsideBounds,
5
+ isPointInsidePolygon,
6
+ isRectCompletelyInsidePolygon,
7
+ isRectOverlappingPolygon
8
+ } from "./chunk-6K6N6UTQ.js";
9
+ import {
10
+ range
11
+ } from "./chunk-KY53E6CT.js";
1
12
  import {
2
13
  pointToSegmentClosestPoint,
3
14
  segmentToBoundsMinDistance,
4
15
  segmentToBoxMinDistance,
5
16
  segmentToCircleMinDistance,
6
17
  segmentToSegmentMinDistance
7
- } from "./chunk-6PD3WN3Y.js";
18
+ } from "./chunk-Y7G4VXR7.js";
19
+ import {
20
+ getUnitVectorFromDirection,
21
+ getUnitVectorFromPointAToB
22
+ } from "./chunk-GIGMPRPV.js";
23
+ import {
24
+ grid
25
+ } from "./chunk-U45EKA3R.js";
8
26
  import {
9
27
  normalizeDegrees
10
28
  } from "./chunk-P6GW5PWY.js";
@@ -13,24 +31,7 @@ import {
13
31
  midpoint,
14
32
  pointToBoundsDistance,
15
33
  pointToBoxDistance
16
- } from "./chunk-BLY7FZPX.js";
17
- import {
18
- clamp,
19
- computeDistanceBetweenBoxes,
20
- computeGapBetweenBoxes,
21
- computeManhattanDistanceBetweenBoxes,
22
- findNearestPointsBetweenBoxSets,
23
- getBoundingBox
24
- } from "./chunk-DRDDWFOS.js";
25
- import "./chunk-MTORG67J.js";
26
- import {
27
- areBoundsCompletelyInsidePolygon,
28
- areBoundsOverlappingPolygon,
29
- isPointInsideBounds,
30
- isPointInsidePolygon,
31
- isRectCompletelyInsidePolygon,
32
- isRectOverlappingPolygon
33
- } from "./chunk-6K6N6UTQ.js";
34
+ } from "./chunk-5J3PCV4D.js";
34
35
  import {
35
36
  distance,
36
37
  doSegmentsIntersect,
@@ -42,8 +43,14 @@ import {
42
43
  pointToSegmentDistance
43
44
  } from "./chunk-EFLPMB4J.js";
44
45
  import {
45
- range
46
- } from "./chunk-KY53E6CT.js";
46
+ clamp,
47
+ computeDistanceBetweenBoxes,
48
+ computeGapBetweenBoxes,
49
+ computeManhattanDistanceBetweenBoxes,
50
+ findNearestPointsBetweenBoxSets,
51
+ getBoundingBox
52
+ } from "./chunk-DRDDWFOS.js";
53
+ import "./chunk-MTORG67J.js";
47
54
  import {
48
55
  boundsAreaOverlap
49
56
  } from "./chunk-YA3GC5BB.js";
@@ -57,16 +64,12 @@ import {
57
64
  doBoundsOverlap
58
65
  } from "./chunk-CA5ORSO4.js";
59
66
  import "./chunk-GYQ2KZV6.js";
67
+ import {
68
+ getBoundsCenter
69
+ } from "./chunk-3WCUPG5S.js";
60
70
  import {
61
71
  getBoundsFromPoints
62
72
  } from "./chunk-5N7UJNVK.js";
63
- import {
64
- getUnitVectorFromDirection,
65
- getUnitVectorFromPointAToB
66
- } from "./chunk-GIGMPRPV.js";
67
- import {
68
- grid
69
- } from "./chunk-U45EKA3R.js";
70
73
  export {
71
74
  areBoundsCompletelyInsidePolygon,
72
75
  areBoundsOverlappingPolygon,
@@ -85,6 +88,7 @@ export {
85
88
  doesSegmentIntersectRect,
86
89
  findNearestPointsBetweenBoxSets,
87
90
  getBoundingBox,
91
+ getBoundsCenter,
88
92
  getBoundsFromPoints,
89
93
  getSegmentIntersection,
90
94
  getUnitVectorFromDirection,
@@ -3,9 +3,9 @@ import {
3
3
  midpoint,
4
4
  pointToBoundsDistance,
5
5
  pointToBoxDistance
6
- } from "./chunk-BLY7FZPX.js";
7
- import "./chunk-DRDDWFOS.js";
6
+ } from "./chunk-5J3PCV4D.js";
8
7
  import "./chunk-EFLPMB4J.js";
8
+ import "./chunk-DRDDWFOS.js";
9
9
  export {
10
10
  distSq,
11
11
  midpoint,
@@ -4,9 +4,9 @@ import {
4
4
  segmentToBoxMinDistance,
5
5
  segmentToCircleMinDistance,
6
6
  segmentToSegmentMinDistance
7
- } from "./chunk-6PD3WN3Y.js";
8
- import "./chunk-DRDDWFOS.js";
7
+ } from "./chunk-Y7G4VXR7.js";
9
8
  import "./chunk-EFLPMB4J.js";
9
+ import "./chunk-DRDDWFOS.js";
10
10
  export {
11
11
  pointToSegmentClosestPoint,
12
12
  segmentToBoundsMinDistance,
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.32",
4
+ "version": "0.0.34",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",