@tscircuit/math-utils 0.0.25 → 0.0.26
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.
- package/README.md +7 -0
- package/dist/{chunk-Y7G4VXR7.js → chunk-6PD3WN3Y.js} +4 -4
- package/dist/{chunk-5J3PCV4D.js → chunk-BLY7FZPX.js} +4 -4
- package/dist/chunk-ZBLDFL2R.js +111 -0
- package/dist/chunk-ZBLDFL2R.js.map +1 -0
- package/dist/common.d.ts +7 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -10
- package/dist/point-distance.js +2 -2
- package/dist/polygon.d.ts +10 -0
- package/dist/polygon.js +16 -0
- package/dist/polygon.js.map +1 -0
- package/dist/segment-distance.js +2 -2
- package/package.json +1 -1
- /package/dist/{chunk-Y7G4VXR7.js.map → chunk-6PD3WN3Y.js.map} +0 -0
- /package/dist/{chunk-5J3PCV4D.js.map → chunk-BLY7FZPX.js.map} +0 -0
package/README.md
CHANGED
|
@@ -71,6 +71,13 @@ console.log("Lines intersect:", intersects)
|
|
|
71
71
|
| [`doBoundsOverlap(bounds1, bounds2)`](./src/bounds-overlap.ts) | Determine if two bounding rectangles overlap. |
|
|
72
72
|
| [`boundsAreaOverlap(bounds1, bounds2)`](./src/bounds-area-overlap.ts) | Area of overlap between two bounding rectangles. |
|
|
73
73
|
| [`boundsDistance(bounds1, bounds2)`](./src/bounds-distance.ts) | Minimum distance between two bounding rectangles. |
|
|
74
|
+
| [`isPointInsidePolygon(point, polygon)`](./src/polygon.ts) | Determine if a point lies inside a polygon. |
|
|
75
|
+
| [`areBoundsOverlappingPolygon(bounds, polygon)`](./src/polygon.ts) | Check whether bounds intersect or are contained by a polygon. |
|
|
76
|
+
| [`areBoundsCompletelyInsidePolygon(bounds, polygon)`](./src/polygon.ts) | Determine if bounds are fully contained within a polygon. |
|
|
77
|
+
| [`isRectOverlappingPolygon(rect, polygon)`](./src/polygon.ts) | Check whether a rectangle defined by `x`, `y`, `width`, and `height` overlaps a polygon. |
|
|
78
|
+
| [`isRectCompletelyInsidePolygon(rect, polygon)`](./src/polygon.ts) | Determine if a rectangle is fully contained within a polygon. |
|
|
79
|
+
|
|
80
|
+
`rect` objects are expected to use the `{ x, y, width, height }` convention with `x` and `y` denoting the minimum corner.
|
|
74
81
|
|
|
75
82
|
## Contributing
|
|
76
83
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clamp
|
|
3
|
+
} from "./chunk-DRDDWFOS.js";
|
|
1
4
|
import {
|
|
2
5
|
distance,
|
|
3
6
|
doSegmentsIntersect,
|
|
4
7
|
pointToSegmentDistance
|
|
5
8
|
} 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-
|
|
112
|
+
//# sourceMappingURL=chunk-6PD3WN3Y.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
distance
|
|
3
|
-
} from "./chunk-EFLPMB4J.js";
|
|
4
1
|
import {
|
|
5
2
|
clamp
|
|
6
3
|
} from "./chunk-DRDDWFOS.js";
|
|
4
|
+
import {
|
|
5
|
+
distance
|
|
6
|
+
} from "./chunk-EFLPMB4J.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-
|
|
49
|
+
//# sourceMappingURL=chunk-BLY7FZPX.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
doSegmentsIntersect
|
|
3
|
+
} from "./chunk-EFLPMB4J.js";
|
|
4
|
+
|
|
5
|
+
// src/polygon.ts
|
|
6
|
+
var rectToBounds = (rect) => ({
|
|
7
|
+
minX: rect.x,
|
|
8
|
+
minY: rect.y,
|
|
9
|
+
maxX: rect.x + rect.width,
|
|
10
|
+
maxY: rect.y + rect.height
|
|
11
|
+
});
|
|
12
|
+
var getBoundsCorners = (bounds) => [
|
|
13
|
+
{ x: bounds.minX, y: bounds.minY },
|
|
14
|
+
{ x: bounds.maxX, y: bounds.minY },
|
|
15
|
+
{ x: bounds.maxX, y: bounds.maxY },
|
|
16
|
+
{ x: bounds.minX, y: bounds.maxY }
|
|
17
|
+
];
|
|
18
|
+
var getPolygonEdges = (polygon) => {
|
|
19
|
+
const edges = [];
|
|
20
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
21
|
+
const start = polygon[i];
|
|
22
|
+
const end = polygon[(i + 1) % polygon.length];
|
|
23
|
+
edges.push([start, end]);
|
|
24
|
+
}
|
|
25
|
+
return edges;
|
|
26
|
+
};
|
|
27
|
+
var isPointOnSegment = (point, start, end) => {
|
|
28
|
+
const cross = (point.y - start.y) * (end.x - start.x) - (point.x - start.x) * (end.y - start.y);
|
|
29
|
+
if (Math.abs(cross) > 1e-9) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const dot = (point.x - start.x) * (end.x - start.x) + (point.y - start.y) * (end.y - start.y);
|
|
33
|
+
if (dot < 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const squaredLength = (end.x - start.x) ** 2 + (end.y - start.y) ** 2;
|
|
37
|
+
if (dot > squaredLength) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
var isPointInsideBounds = (point, bounds) => point.x >= bounds.minX && point.x <= bounds.maxX && point.y >= bounds.minY && point.y <= bounds.maxY;
|
|
43
|
+
var isPointInsidePolygon = (point, polygon) => {
|
|
44
|
+
if (polygon.length < 3) return false;
|
|
45
|
+
const edges = getPolygonEdges(polygon);
|
|
46
|
+
for (const [start, end] of edges) {
|
|
47
|
+
if (isPointOnSegment(point, start, end)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let inside = false;
|
|
52
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
53
|
+
const xi = polygon[i].x;
|
|
54
|
+
const yi = polygon[i].y;
|
|
55
|
+
const xj = polygon[j].x;
|
|
56
|
+
const yj = polygon[j].y;
|
|
57
|
+
const intersects = yi > point.y !== yj > point.y && point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi;
|
|
58
|
+
if (intersects) {
|
|
59
|
+
inside = !inside;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return inside;
|
|
63
|
+
};
|
|
64
|
+
var doesPolygonIntersectBounds = (bounds, polygon) => {
|
|
65
|
+
const boundsCorners = getBoundsCorners(bounds);
|
|
66
|
+
const boundsEdges = [
|
|
67
|
+
[boundsCorners[0], boundsCorners[1]],
|
|
68
|
+
[boundsCorners[1], boundsCorners[2]],
|
|
69
|
+
[boundsCorners[2], boundsCorners[3]],
|
|
70
|
+
[boundsCorners[3], boundsCorners[0]]
|
|
71
|
+
];
|
|
72
|
+
const polygonEdges = getPolygonEdges(polygon);
|
|
73
|
+
for (const [start, end] of polygonEdges) {
|
|
74
|
+
for (const [rectStart, rectEnd] of boundsEdges) {
|
|
75
|
+
if (doSegmentsIntersect(start, end, rectStart, rectEnd)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
};
|
|
82
|
+
var areBoundsOverlappingPolygon = (bounds, polygon) => {
|
|
83
|
+
if (polygon.length < 3) return false;
|
|
84
|
+
if (polygon.some((point) => isPointInsideBounds(point, bounds))) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const corners = getBoundsCorners(bounds);
|
|
88
|
+
if (corners.some((corner) => isPointInsidePolygon(corner, polygon))) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
return doesPolygonIntersectBounds(bounds, polygon);
|
|
92
|
+
};
|
|
93
|
+
var areBoundsCompletelyInsidePolygon = (bounds, polygon) => {
|
|
94
|
+
if (polygon.length < 3) return false;
|
|
95
|
+
const corners = getBoundsCorners(bounds);
|
|
96
|
+
if (!corners.every((corner) => isPointInsidePolygon(corner, polygon))) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return !doesPolygonIntersectBounds(bounds, polygon);
|
|
100
|
+
};
|
|
101
|
+
var isRectOverlappingPolygon = (rect, polygon) => areBoundsOverlappingPolygon(rectToBounds(rect), polygon);
|
|
102
|
+
var isRectCompletelyInsidePolygon = (rect, polygon) => areBoundsCompletelyInsidePolygon(rectToBounds(rect), polygon);
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
isPointInsidePolygon,
|
|
106
|
+
areBoundsOverlappingPolygon,
|
|
107
|
+
areBoundsCompletelyInsidePolygon,
|
|
108
|
+
isRectOverlappingPolygon,
|
|
109
|
+
isRectCompletelyInsidePolygon
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=chunk-ZBLDFL2R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/polygon.ts"],"sourcesContent":["import type { Bounds, Point, Rect } from \"./common\"\nimport { doSegmentsIntersect } from \"./line-intersections\"\n\nexport type Polygon = readonly Point[]\n\nconst rectToBounds = (rect: Rect): Bounds => ({\n minX: rect.x,\n minY: rect.y,\n maxX: rect.x + rect.width,\n maxY: rect.y + rect.height,\n})\n\nconst getBoundsCorners = (bounds: Bounds): Point[] => [\n { x: bounds.minX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.minY },\n { x: bounds.maxX, y: bounds.maxY },\n { x: bounds.minX, y: bounds.maxY },\n]\n\nconst getPolygonEdges = (polygon: Polygon): Array<[Point, Point]> => {\n const edges: Array<[Point, Point]> = []\n for (let i = 0; i < polygon.length; i++) {\n const start = polygon[i]\n const end = polygon[(i + 1) % polygon.length]\n edges.push([start, end])\n }\n return edges\n}\n\nconst isPointOnSegment = (point: Point, start: Point, end: Point): boolean => {\n const cross =\n (point.y - start.y) * (end.x - start.x) -\n (point.x - start.x) * (end.y - start.y)\n if (Math.abs(cross) > 1e-9) {\n return false\n }\n\n const dot =\n (point.x - start.x) * (end.x - start.x) +\n (point.y - start.y) * (end.y - start.y)\n if (dot < 0) {\n return false\n }\n\n const squaredLength = (end.x - start.x) ** 2 + (end.y - start.y) ** 2\n if (dot > squaredLength) {\n return false\n }\n\n return true\n}\n\nconst isPointInsideBounds = (point: Point, bounds: Bounds): boolean =>\n point.x >= bounds.minX &&\n point.x <= bounds.maxX &&\n point.y >= bounds.minY &&\n point.y <= bounds.maxY\n\nexport const isPointInsidePolygon = (\n point: Point,\n polygon: Polygon,\n): boolean => {\n if (polygon.length < 3) return false\n\n const edges = getPolygonEdges(polygon)\n for (const [start, end] of edges) {\n if (isPointOnSegment(point, start, end)) {\n return true\n }\n }\n\n let inside = false\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x\n const yi = polygon[i].y\n const xj = polygon[j].x\n const yj = polygon[j].y\n\n const intersects =\n yi > point.y !== yj > point.y &&\n point.x < ((xj - xi) * (point.y - yi)) / (yj - yi) + xi\n\n if (intersects) {\n inside = !inside\n }\n }\n\n return inside\n}\n\nconst doesPolygonIntersectBounds = (\n bounds: Bounds,\n polygon: Polygon,\n): boolean => {\n const boundsCorners = getBoundsCorners(bounds)\n const boundsEdges: Array<[Point, Point]> = [\n [boundsCorners[0], boundsCorners[1]],\n [boundsCorners[1], boundsCorners[2]],\n [boundsCorners[2], boundsCorners[3]],\n [boundsCorners[3], boundsCorners[0]],\n ]\n\n const polygonEdges = getPolygonEdges(polygon)\n\n for (const [start, end] of polygonEdges) {\n for (const [rectStart, rectEnd] of boundsEdges) {\n if (doSegmentsIntersect(start, end, rectStart, rectEnd)) {\n return true\n }\n }\n }\n\n return false\n}\n\nexport const areBoundsOverlappingPolygon = (\n bounds: Bounds,\n polygon: Polygon,\n): boolean => {\n if (polygon.length < 3) return false\n\n if (polygon.some((point) => isPointInsideBounds(point, bounds))) {\n return true\n }\n\n const corners = getBoundsCorners(bounds)\n if (corners.some((corner) => isPointInsidePolygon(corner, polygon))) {\n return true\n }\n\n return doesPolygonIntersectBounds(bounds, polygon)\n}\n\nexport const areBoundsCompletelyInsidePolygon = (\n bounds: Bounds,\n polygon: Polygon,\n): boolean => {\n if (polygon.length < 3) return false\n\n const corners = getBoundsCorners(bounds)\n if (!corners.every((corner) => isPointInsidePolygon(corner, polygon))) {\n return false\n }\n\n return !doesPolygonIntersectBounds(bounds, polygon)\n}\n\nexport const isRectOverlappingPolygon = (\n rect: Rect,\n polygon: Polygon,\n): boolean => areBoundsOverlappingPolygon(rectToBounds(rect), polygon)\n\nexport const isRectCompletelyInsidePolygon = (\n rect: Rect,\n polygon: Polygon,\n): boolean => areBoundsCompletelyInsidePolygon(rectToBounds(rect), polygon)\n"],"mappings":";;;;;AAKA,IAAM,eAAe,CAAC,UAAwB;AAAA,EAC5C,MAAM,KAAK;AAAA,EACX,MAAM,KAAK;AAAA,EACX,MAAM,KAAK,IAAI,KAAK;AAAA,EACpB,MAAM,KAAK,IAAI,KAAK;AACtB;AAEA,IAAM,mBAAmB,CAAC,WAA4B;AAAA,EACpD,EAAE,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAAA,EACjC,EAAE,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAAA,EACjC,EAAE,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAAA,EACjC,EAAE,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AACnC;AAEA,IAAM,kBAAkB,CA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Y;AACZ,MAAI,QAAQ,SAAS,EAAG,QAAO;AAE/B,QAAM,UAAU,iBAAiB,MAAM;AACvC,MAAI,CAAC,QAAQ,MAAM,CAAC,WAAW,qBAAqB,QAAQ,OAAO,CAAC,GAAG;AACrE,WAAO;AAAA,EACT;AAEA,SAAO,CAAC,2BAA2B,QAAQ,OAAO;AACpD;AAEO,IAAM,2BAA2B,CACtC,MACA,YACY,4BAA4B,aAAa,IAAI,GAAG,OAAO;AAE9D,IAAM,gCAAgC,CAC3C,MACA,YACY,iCAAiC,aAAa,IAAI,GAAG,OAAO;","names":[]}
|
package/dist/common.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { distance, doSegmentsIntersect, doesLineIntersectLine, doesSegmentIntersectRect, getSegmentIntersection, onSegment, orientation, pointToSegmentDistance } from './line-intersections.js';
|
|
2
2
|
export { Box, BoxSet, GridCell, clamp, computeDistanceBetweenBoxes, computeGapBetweenBoxes, computeManhattanDistanceBetweenBoxes, findNearestPointsBetweenBoxSets, getBoundingBox } from './nearest-box.js';
|
|
3
|
-
export { Bounds, Point } from './common.js';
|
|
3
|
+
export { Bounds, Point, Rect } from './common.js';
|
|
4
4
|
export { getUnitVectorFromDirection, getUnitVectorFromPointAToB } from './get-unit-vector.js';
|
|
5
5
|
export { GridCellPositions, GridOptions, grid } from './grid.js';
|
|
6
6
|
export { pointToSegmentClosestPoint, segmentToBoundsMinDistance, segmentToBoxMinDistance, segmentToCircleMinDistance, segmentToSegmentMinDistance } from './segment-distance.js';
|
|
@@ -11,3 +11,4 @@ export { doBoundsOverlap } from './bounds-overlap.js';
|
|
|
11
11
|
export { boundsAreaOverlap } from './bounds-area-overlap.js';
|
|
12
12
|
export { boundsDistance } from './bounds-distance.js';
|
|
13
13
|
export { boundsIntersection } from './bounds-intersection.js';
|
|
14
|
+
export { Polygon, areBoundsCompletelyInsidePolygon, areBoundsOverlappingPolygon, isPointInsidePolygon, isRectCompletelyInsidePolygon, isRectOverlappingPolygon } from './polygon.js';
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,15 @@ import {
|
|
|
3
3
|
midpoint,
|
|
4
4
|
pointToBoundsDistance,
|
|
5
5
|
pointToBoxDistance
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BLY7FZPX.js";
|
|
7
7
|
import "./chunk-MTORG67J.js";
|
|
8
|
+
import {
|
|
9
|
+
areBoundsCompletelyInsidePolygon,
|
|
10
|
+
areBoundsOverlappingPolygon,
|
|
11
|
+
isPointInsidePolygon,
|
|
12
|
+
isRectCompletelyInsidePolygon,
|
|
13
|
+
isRectOverlappingPolygon
|
|
14
|
+
} from "./chunk-ZBLDFL2R.js";
|
|
8
15
|
import {
|
|
9
16
|
range
|
|
10
17
|
} from "./chunk-KY53E6CT.js";
|
|
@@ -14,7 +21,15 @@ import {
|
|
|
14
21
|
segmentToBoxMinDistance,
|
|
15
22
|
segmentToCircleMinDistance,
|
|
16
23
|
segmentToSegmentMinDistance
|
|
17
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-6PD3WN3Y.js";
|
|
25
|
+
import {
|
|
26
|
+
clamp,
|
|
27
|
+
computeDistanceBetweenBoxes,
|
|
28
|
+
computeGapBetweenBoxes,
|
|
29
|
+
computeManhattanDistanceBetweenBoxes,
|
|
30
|
+
findNearestPointsBetweenBoxSets,
|
|
31
|
+
getBoundingBox
|
|
32
|
+
} from "./chunk-DRDDWFOS.js";
|
|
18
33
|
import {
|
|
19
34
|
distance,
|
|
20
35
|
doSegmentsIntersect,
|
|
@@ -25,14 +40,6 @@ import {
|
|
|
25
40
|
orientation,
|
|
26
41
|
pointToSegmentDistance
|
|
27
42
|
} from "./chunk-EFLPMB4J.js";
|
|
28
|
-
import {
|
|
29
|
-
clamp,
|
|
30
|
-
computeDistanceBetweenBoxes,
|
|
31
|
-
computeGapBetweenBoxes,
|
|
32
|
-
computeManhattanDistanceBetweenBoxes,
|
|
33
|
-
findNearestPointsBetweenBoxSets,
|
|
34
|
-
getBoundingBox
|
|
35
|
-
} from "./chunk-DRDDWFOS.js";
|
|
36
43
|
import {
|
|
37
44
|
boundsAreaOverlap
|
|
38
45
|
} from "./chunk-YA3GC5BB.js";
|
|
@@ -54,6 +61,8 @@ import {
|
|
|
54
61
|
grid
|
|
55
62
|
} from "./chunk-U45EKA3R.js";
|
|
56
63
|
export {
|
|
64
|
+
areBoundsCompletelyInsidePolygon,
|
|
65
|
+
areBoundsOverlappingPolygon,
|
|
57
66
|
boundsAreaOverlap,
|
|
58
67
|
boundsDistance,
|
|
59
68
|
boundsIntersection,
|
|
@@ -73,6 +82,9 @@ export {
|
|
|
73
82
|
getUnitVectorFromDirection,
|
|
74
83
|
getUnitVectorFromPointAToB,
|
|
75
84
|
grid,
|
|
85
|
+
isPointInsidePolygon,
|
|
86
|
+
isRectCompletelyInsidePolygon,
|
|
87
|
+
isRectOverlappingPolygon,
|
|
76
88
|
midpoint,
|
|
77
89
|
onSegment,
|
|
78
90
|
orientation,
|
package/dist/point-distance.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
midpoint,
|
|
4
4
|
pointToBoundsDistance,
|
|
5
5
|
pointToBoxDistance
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-EFLPMB4J.js";
|
|
6
|
+
} from "./chunk-BLY7FZPX.js";
|
|
8
7
|
import "./chunk-DRDDWFOS.js";
|
|
8
|
+
import "./chunk-EFLPMB4J.js";
|
|
9
9
|
export {
|
|
10
10
|
distSq,
|
|
11
11
|
midpoint,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Point, Bounds, Rect } from './common.js';
|
|
2
|
+
|
|
3
|
+
type Polygon = readonly Point[];
|
|
4
|
+
declare const isPointInsidePolygon: (point: Point, polygon: Polygon) => boolean;
|
|
5
|
+
declare const areBoundsOverlappingPolygon: (bounds: Bounds, polygon: Polygon) => boolean;
|
|
6
|
+
declare const areBoundsCompletelyInsidePolygon: (bounds: Bounds, polygon: Polygon) => boolean;
|
|
7
|
+
declare const isRectOverlappingPolygon: (rect: Rect, polygon: Polygon) => boolean;
|
|
8
|
+
declare const isRectCompletelyInsidePolygon: (rect: Rect, polygon: Polygon) => boolean;
|
|
9
|
+
|
|
10
|
+
export { type Polygon, areBoundsCompletelyInsidePolygon, areBoundsOverlappingPolygon, isPointInsidePolygon, isRectCompletelyInsidePolygon, isRectOverlappingPolygon };
|
package/dist/polygon.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
areBoundsCompletelyInsidePolygon,
|
|
3
|
+
areBoundsOverlappingPolygon,
|
|
4
|
+
isPointInsidePolygon,
|
|
5
|
+
isRectCompletelyInsidePolygon,
|
|
6
|
+
isRectOverlappingPolygon
|
|
7
|
+
} from "./chunk-ZBLDFL2R.js";
|
|
8
|
+
import "./chunk-EFLPMB4J.js";
|
|
9
|
+
export {
|
|
10
|
+
areBoundsCompletelyInsidePolygon,
|
|
11
|
+
areBoundsOverlappingPolygon,
|
|
12
|
+
isPointInsidePolygon,
|
|
13
|
+
isRectCompletelyInsidePolygon,
|
|
14
|
+
isRectOverlappingPolygon
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=polygon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/segment-distance.js
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
segmentToBoxMinDistance,
|
|
5
5
|
segmentToCircleMinDistance,
|
|
6
6
|
segmentToSegmentMinDistance
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-EFLPMB4J.js";
|
|
7
|
+
} from "./chunk-6PD3WN3Y.js";
|
|
9
8
|
import "./chunk-DRDDWFOS.js";
|
|
9
|
+
import "./chunk-EFLPMB4J.js";
|
|
10
10
|
export {
|
|
11
11
|
pointToSegmentClosestPoint,
|
|
12
12
|
segmentToBoundsMinDistance,
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|