@tscircuit/math-utils 0.0.24 → 0.0.25

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,11 @@
1
+ import { Bounds } from './common.js';
2
+
3
+ /**
4
+ * Calculates the overlapping bounds of two rectangles
5
+ * @param bounds1 First bounding rectangle
6
+ * @param bounds2 Second bounding rectangle
7
+ * @returns The overlapping bounds or null if there is no overlap
8
+ */
9
+ declare const boundsIntersection: (bounds1: Bounds, bounds2: Bounds) => Bounds | null;
10
+
11
+ export { boundsIntersection };
@@ -0,0 +1,7 @@
1
+ import {
2
+ boundsIntersection
3
+ } from "./chunk-S7H7MIDL.js";
4
+ export {
5
+ boundsIntersection
6
+ };
7
+ //# sourceMappingURL=bounds-intersection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","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
@@ -0,0 +1,16 @@
1
+ // src/bounds-intersection.ts
2
+ var boundsIntersection = (bounds1, bounds2) => {
3
+ const minX = Math.max(bounds1.minX, bounds2.minX);
4
+ const minY = Math.max(bounds1.minY, bounds2.minY);
5
+ const maxX = Math.min(bounds1.maxX, bounds2.maxX);
6
+ const maxY = Math.min(bounds1.maxY, bounds2.maxY);
7
+ if (minX > maxX || minY > maxY) {
8
+ return null;
9
+ }
10
+ return { minX, minY, maxX, maxY };
11
+ };
12
+
13
+ export {
14
+ boundsIntersection
15
+ };
16
+ //# sourceMappingURL=chunk-S7H7MIDL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bounds-intersection.ts"],"sourcesContent":["import type { Bounds } from \"./common\"\n\n/**\n * Calculates the overlapping bounds of two rectangles\n * @param bounds1 First bounding rectangle\n * @param bounds2 Second bounding rectangle\n * @returns The overlapping bounds or null if there is no overlap\n */\nexport const boundsIntersection = (\n bounds1: Bounds,\n bounds2: Bounds,\n): Bounds | null => {\n const minX = Math.max(bounds1.minX, bounds2.minX)\n const minY = Math.max(bounds1.minY, bounds2.minY)\n const maxX = Math.min(bounds1.maxX, bounds2.maxX)\n const maxY = Math.min(bounds1.maxY, bounds2.maxY)\n\n if (minX > maxX || minY > maxY) {\n return null\n }\n\n return { minX, minY, maxX, maxY }\n}\n"],"mappings":";AAQO,IAAM,qBAAqB,CAChC,SACA,YACkB;AAClB,QAAM,OAAO,KAAK,IAAI,QAAQ,MAAM,QAAQ,IAAI;AAChD,QAAM,OAAO,KAAK,IAAI,QAAQ,MAAM,QAAQ,IAAI;AAChD,QAAM,OAAO,KAAK,IAAI,QAAQ,MAAM,QAAQ,IAAI;AAChD,QAAM,OAAO,KAAK,IAAI,QAAQ,MAAM,QAAQ,IAAI;AAEhD,MAAI,OAAO,QAAQ,OAAO,MAAM;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,MAAM,MAAM,KAAK;AAClC;","names":[]}
@@ -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
package/dist/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export { range } from './range.js';
10
10
  export { doBoundsOverlap } from './bounds-overlap.js';
11
11
  export { boundsAreaOverlap } from './bounds-area-overlap.js';
12
12
  export { boundsDistance } from './bounds-distance.js';
13
+ export { boundsIntersection } from './bounds-intersection.js';
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  midpoint,
4
4
  pointToBoundsDistance,
5
5
  pointToBoxDistance
6
- } from "./chunk-BLY7FZPX.js";
6
+ } from "./chunk-5J3PCV4D.js";
7
7
  import "./chunk-MTORG67J.js";
8
8
  import {
9
9
  range
@@ -14,7 +14,17 @@ import {
14
14
  segmentToBoxMinDistance,
15
15
  segmentToCircleMinDistance,
16
16
  segmentToSegmentMinDistance
17
- } from "./chunk-6PD3WN3Y.js";
17
+ } from "./chunk-Y7G4VXR7.js";
18
+ import {
19
+ distance,
20
+ doSegmentsIntersect,
21
+ doesLineIntersectLine,
22
+ doesSegmentIntersectRect,
23
+ getSegmentIntersection,
24
+ onSegment,
25
+ orientation,
26
+ pointToSegmentDistance
27
+ } from "./chunk-EFLPMB4J.js";
18
28
  import {
19
29
  clamp,
20
30
  computeDistanceBetweenBoxes,
@@ -29,6 +39,9 @@ import {
29
39
  import {
30
40
  boundsDistance
31
41
  } from "./chunk-KVGAXIWH.js";
42
+ import {
43
+ boundsIntersection
44
+ } from "./chunk-S7H7MIDL.js";
32
45
  import {
33
46
  doBoundsOverlap
34
47
  } from "./chunk-CA5ORSO4.js";
@@ -40,19 +53,10 @@ import {
40
53
  import {
41
54
  grid
42
55
  } from "./chunk-U45EKA3R.js";
43
- import {
44
- distance,
45
- doSegmentsIntersect,
46
- doesLineIntersectLine,
47
- doesSegmentIntersectRect,
48
- getSegmentIntersection,
49
- onSegment,
50
- orientation,
51
- pointToSegmentDistance
52
- } from "./chunk-EFLPMB4J.js";
53
56
  export {
54
57
  boundsAreaOverlap,
55
58
  boundsDistance,
59
+ boundsIntersection,
56
60
  clamp,
57
61
  computeDistanceBetweenBoxes,
58
62
  computeGapBetweenBoxes,
@@ -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.24",
4
+ "version": "0.0.25",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",