소스정리2

This commit is contained in:
yscha 2025-12-06 00:24:55 +09:00
parent 4d2b872183
commit c6c5fabbf2

View File

@ -2387,49 +2387,7 @@ function getLineDirection(p1, p2) {
/**
* 점이 선분 위에 있는지 확인하는 헬퍼 함수
* @param {Object} point - 확인할 {x, y}
* @param {Object} lineStart - 선분의 시작점 {x, y}
* @param {Object} lineEnd - 선분의 끝점 {x, y}
* @param {number} epsilon - 허용 오차
* @returns {boolean}
*/
// function isPointOnLineSegment(point, lineStart, lineEnd, epsilon = 0.1) {
// const dx = lineEnd.x - lineStart.x;
// const dy = lineEnd.y - lineStart.y;
// const length = Math.sqrt(dx * dx + dy * dy);
//
// if (length === 0) {
// // 선분의 길이가 0이면 시작점과의 거리만 확인
// return Math.abs(point.x - lineStart.x) < epsilon && Math.abs(point.y - lineStart.y) < epsilon;
// }
//
// // 점에서 선분의 시작점까지의 벡터
// const toPoint = { x: point.x - lineStart.x, y: point.y - lineStart.y };
//
// // 선분 방향으로의 투영 길이
// const t = (toPoint.x * dx + toPoint.y * dy) / (length * length);
//
// // t가 0과 1 사이에 있어야 선분 위에 있음
// if (t < 0 || t > 1) {
// return false;
// }
//
// // 선분 위의 가장 가까운 점
// const closestPoint = {
// x: lineStart.x + t * dx,
// y: lineStart.y + t * dy
// };
//
// // 점과 가장 가까운 점 사이의 거리
// const dist = Math.sqrt(
// Math.pow(point.x - closestPoint.x, 2) +
// Math.pow(point.y - closestPoint.y, 2)
// );
//
// return dist < epsilon;
// }
// selectLine과 baseLines 비교하여 방향 찾기
function findLineDirection(selectLine, baseLines) {