Files
lan-manager/web/node_modules/@antv/path-util/lib/get-line-intersect.js
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

37 lines
1.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var isBetween = function (value, min, max) { return value >= min && value <= max; };
function getLineIntersect(p0, p1, p2, p3) {
var tolerance = 0.001;
var E = {
x: p2.x - p0.x,
y: p2.y - p0.y,
};
var D0 = {
x: p1.x - p0.x,
y: p1.y - p0.y,
};
var D1 = {
x: p3.x - p2.x,
y: p3.y - p2.y,
};
var kross = D0.x * D1.y - D0.y * D1.x;
var sqrKross = kross * kross;
var sqrLen0 = D0.x * D0.x + D0.y * D0.y;
var sqrLen1 = D1.x * D1.x + D1.y * D1.y;
var point = null;
if (sqrKross > tolerance * sqrLen0 * sqrLen1) {
var s = (E.x * D1.y - E.y * D1.x) / kross;
var t = (E.x * D0.y - E.y * D0.x) / kross;
if (isBetween(s, 0, 1) && isBetween(t, 0, 1)) {
point = {
x: p0.x + s * D0.x,
y: p0.y + s * D0.y,
};
}
}
return point;
}
exports.default = getLineIntersect;
;
//# sourceMappingURL=get-line-intersect.js.map