@tscircuit/math-utils 0.0.25 → 0.0.27
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-RCZE5Q5V.js +118 -0
- package/dist/chunk-RCZE5Q5V.js.map +1 -0
- package/dist/common.d.ts +12 -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 a center point with dimensions or by bounds overlaps a polygon. |
|
|
78
|
+
| [`isRectCompletelyInsidePolygon(rect, polygon)`](./src/polygon.ts) | Determine if a rectangle defined by a center point with dimensions or by bounds is fully contained within a polygon. |
|
|
79
|
+
|
|
80
|
+
`rect` objects passed to these helpers can either specify a `center` along with `width` and `height` or provide `Bounds` directly.
|
|
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,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
doSegmentsIntersect
|
|
3
|
+
} from "./chunk-EFLPMB4J.js";
|
|
4
|
+
|
|
5
|
+
// src/polygon.ts
|
|
6
|
+
var universalRectToBounds = (rect) => {
|
|
7
|
+
if ("minX" in rect) {
|
|
8
|
+
return rect;
|
|
9
|
+
}
|
|
10
|
+
const halfWidth = rect.width / 2;
|
|
11
|
+
const halfHeight = rect.height / 2;
|
|
12
|
+
return {
|
|
13
|
+
minX: rect.center.x - halfWidth,
|
|
14
|
+
minY: rect.center.y - halfHeight,
|
|
15
|
+
maxX: rect.center.x + halfWidth,
|
|
16
|
+
maxY: rect.center.y + halfHeight
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
var getBoundsCorners = (bounds) => [
|
|
20
|
+
{ x: bounds.minX, y: bounds.minY },
|
|
21
|
+
{ x: bounds.maxX, y: bounds.minY },
|
|
22
|
+
{ x: bounds.maxX, y: bounds.maxY },
|
|
23
|
+
{ x: bounds.minX, y: bounds.maxY }
|
|
24
|
+
];
|
|
25
|
+
var getPolygonEdges = (polygon) => {
|
|
26
|
+
const edges = [];
|
|
27
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
28
|
+
const start = polygon[i];
|
|
29
|
+
const end = polygon[(i + 1) % polygon.length];
|
|
30
|
+
edges.push([start, end]);
|
|
31
|
+
}
|
|
32
|
+
return edges;
|
|
33
|
+
};
|
|
34
|
+
var isPointOnSegment = (point, start, end) => {
|
|
35
|
+
const cross = (point.y - start.y) * (end.x - start.x) - (point.x - start.x) * (end.y - start.y);
|
|
36
|
+
if (Math.abs(cross) > 1e-9) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const dot = (point.x - start.x) * (end.x - start.x) + (point.y - start.y) * (end.y - start.y);
|
|
40
|
+
if (dot < 0) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const squaredLength = (end.x - start.x) ** 2 + (end.y - start.y) ** 2;
|
|
44
|
+
if (dot > squaredLength) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
var isPointInsideBounds = (point, bounds) => point.x >= bounds.minX && point.x <= bounds.maxX && point.y >= bounds.minY && point.y <= bounds.maxY;
|
|
50
|
+
var isPointInsidePolygon = (point, polygon) => {
|
|
51
|
+
if (polygon.length < 3) return false;
|
|
52
|
+
const edges = getPolygonEdges(polygon);
|
|
53
|
+
for (const [start, end] of edges) {
|
|
54
|
+
if (isPointOnSegment(point, start, end)) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let inside = false;
|
|
59
|
+
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
60
|
+
const xi = polygon[i].x;
|
|
61
|
+
const yi = polygon[i].y;
|
|
62
|
+
const xj = polygon[j].x;
|
|
63
|
+
const yj = polygon[j].y;
|
|
64
|
+
const intersects = yi > point.y !== yj > point.y && point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi;
|
|
65
|
+
if (intersects) {
|
|
66
|
+
inside = !inside;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return inside;
|
|
70
|
+
};
|
|
71
|
+
var doesPolygonIntersectBounds = (bounds, polygon) => {
|
|
72
|
+
const boundsCorners = getBoundsCorners(bounds);
|
|
73
|
+
const boundsEdges = [
|
|
74
|
+
[boundsCorners[0], boundsCorners[1]],
|
|
75
|
+
[boundsCorners[1], boundsCorners[2]],
|
|
76
|
+
[boundsCorners[2], boundsCorners[3]],
|
|
77
|
+
[boundsCorners[3], boundsCorners[0]]
|
|
78
|
+
];
|
|
79
|
+
const polygonEdges = getPolygonEdges(polygon);
|
|
80
|
+
for (const [start, end] of polygonEdges) {
|
|
81
|
+
for (const [rectStart, rectEnd] of boundsEdges) {
|
|
82
|
+
if (doSegmentsIntersect(start, end, rectStart, rectEnd)) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
89
|
+
var areBoundsOverlappingPolygon = (bounds, polygon) => {
|
|
90
|
+
if (polygon.length < 3) return false;
|
|
91
|
+
if (polygon.some((point) => isPointInsideBounds(point, bounds))) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const corners = getBoundsCorners(bounds);
|
|
95
|
+
if (corners.some((corner) => isPointInsidePolygon(corner, polygon))) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return doesPolygonIntersectBounds(bounds, polygon);
|
|
99
|
+
};
|
|
100
|
+
var areBoundsCompletelyInsidePolygon = (bounds, polygon) => {
|
|
101
|
+
if (polygon.length < 3) return false;
|
|
102
|
+
const corners = getBoundsCorners(bounds);
|
|
103
|
+
if (!corners.every((corner) => isPointInsidePolygon(corner, polygon))) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return !doesPolygonIntersectBounds(bounds, polygon);
|
|
107
|
+
};
|
|
108
|
+
var isRectOverlappingPolygon = (rect, polygon) => areBoundsOverlappingPolygon(universalRectToBounds(rect), polygon);
|
|
109
|
+
var isRectCompletelyInsidePolygon = (rect, polygon) => areBoundsCompletelyInsidePolygon(universalRectToBounds(rect), polygon);
|
|
110
|
+
|
|
111
|
+
export {
|
|
112
|
+
isPointInsidePolygon,
|
|
113
|
+
areBoundsOverlappingPolygon,
|
|
114
|
+
areBoundsCompletelyInsidePolygon,
|
|
115
|
+
isRectOverlappingPolygon,
|
|
116
|
+
isRectCompletelyInsidePolygon
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=chunk-RCZE5Q5V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/polygon.ts"],"sourcesContent":["import type { Bounds, Point, UniversalRect } from \"./common\"\nimport { doSegmentsIntersect } from \"./line-intersections\"\n\nexport type Polygon = readonly Point[]\n\nconst universalRectToBounds = (rect: UniversalRect): Bounds => {\n if (\"minX\" in rect) {\n return rect\n }\n\n const halfWidth = rect.width / 2\n const halfHeight = rect.height / 2\n\n return {\n minX: rect.center.x - halfWidth,\n minY: rect.center.y - halfHeight,\n maxX: rect.center.x + halfWidth,\n maxY: rect.center.y + halfHeight,\n }\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: UniversalRect,\n polygon: Polygon,\n): boolean => areBoundsOverlappingPolygon(universalRectToBounds(rect), polygon)\n\nexport const isRectCompletelyInsidePolygon = (\n rect: UniversalRect,\n polygon: Polygon,\n): boolean =>\n areBoundsCompletelyInsidePolygon(universalRectToBounds(rect), polygon)\n"],"mappings":";;;;;AAKA,IAAM,wBAAwB,CAAC,SAAgC;AAC7D,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,KAAK,QA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aAAa;AAC9C,UAAI,oBAAoB,OAAO,KAAK,WAAW,OAAO,GAAG;AACvD,eAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,IAAM,8BAA8B,CACzC,QACA,YACY;AACZ,MAAI,QAAQ,SAAS,EAAG,QAAO;AAE/B,MAAI,QAAQ,KAAK,CAAC,UAAU,oBAAoB,OAAO,MAAM,CAAC,GAAG;AAC/D,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,iBAAiB,MAAM;AACvC,MAAI,QAAQ,KAAK,CAAC,WAAW,qBAAqB,QAAQ,OAAO,CAAC,GAAG;AACnE,WAAO;AAAA,EACT;AAEA,SAAO,2BAA2B,QAAQ,OAAO;AACnD;AAEO,IAAM,mCAAmC,CAC9C,QACA,YACY;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,sBAAsB,IAAI,GAAG,OAAO;AAEvE,IAAM,gCAAgC,CAC3C,MACA,YAEA,iCAAiC,sBAAsB,IAAI,GAAG,OAAO;","names":[]}
|
package/dist/common.d.ts
CHANGED
|
@@ -8,5 +8,16 @@ type Bounds = {
|
|
|
8
8
|
maxX: number;
|
|
9
9
|
maxY: number;
|
|
10
10
|
};
|
|
11
|
+
type Rect = {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
};
|
|
17
|
+
type UniversalRect = {
|
|
18
|
+
center: Point;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
} | Bounds;
|
|
11
22
|
|
|
12
|
-
export type { Bounds, Point };
|
|
23
|
+
export type { Bounds, Point, Rect, UniversalRect };
|
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, UniversalRect } 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-RCZE5Q5V.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, UniversalRect } 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: UniversalRect, polygon: Polygon) => boolean;
|
|
8
|
+
declare const isRectCompletelyInsidePolygon: (rect: UniversalRect, 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-RCZE5Q5V.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
|