라인 위에 있는지 확인 함수 수정

지붕재 할당 시 오류 수정
This commit is contained in:
hyojun.choi 2025-04-30 13:08:58 +09:00
parent 9f88880ac2
commit 8412462a8b
3 changed files with 133 additions and 129 deletions

View File

@ -23,6 +23,7 @@ export function useRoofFn() {
//면형상 선택 클릭시 지붕 패턴 입히기 //면형상 선택 클릭시 지붕 패턴 입히기
function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial, isForceChange = false, isDisplay = false) { function setSurfaceShapePattern(polygon, mode = 'onlyBorder', trestleMode = false, roofMaterial, isForceChange = false, isDisplay = false) {
try {
if (!polygon) { if (!polygon) {
return return
} }
@ -169,6 +170,9 @@ export function useRoofFn() {
polygon.set('fill', pattern) polygon.set('fill', pattern)
polygon.roofMaterial = roofMaterial polygon.roofMaterial = roofMaterial
polygon.canvas?.renderAll() polygon.canvas?.renderAll()
} catch (e) {
console.log(e)
}
} }
function removeRoofMaterial(roof = currentObject) { function removeRoofMaterial(roof = currentObject) {

View File

@ -1234,13 +1234,13 @@ export const usePolygon = () => {
function getPath(start, end, graph, epsilon = 1) { function getPath(start, end, graph, epsilon = 1) {
if (isDirectlyConnected(start, end, graph, epsilon)) { if (isDirectlyConnected(start, end, graph, epsilon)) {
console.log('직선 연결 있음. 무시.') console.log('직선 연결 있음. 무시.')
return null return []
} }
const path = findShortestPath(start, end, graph, epsilon) const path = findShortestPath(start, end, graph, epsilon)
if (!path || path.length < 3) { if (!path || path.length < 3) {
console.log('경로 존재하나 3개 미만 좌표. 무시.') console.log('경로 존재하나 3개 미만 좌표. 무시.')
return null return []
} }
return path return path

View File

@ -520,17 +520,17 @@ export const sortedPointLessEightPoint = (points) => {
// 직선의 방정식. // 직선의 방정식.
// 방정식은 ax + by + c = 0이며, 점의 좌표를 대입하여 계산된 값은 직선과 점 사이의 관계를 나타낸다. // 방정식은 ax + by + c = 0이며, 점의 좌표를 대입하여 계산된 값은 직선과 점 사이의 관계를 나타낸다.
export function isPointOnLine({ x1, y1, x2, y2 }, { x, y }, epsilon = 2) { export function isPointOnLine({ x1, y1, x2, y2 }, { x, y }, epsilon = 2) {
const a = y2 - y1 /*const a = y2 - y1
const b = x1 - x2 const b = x1 - x2
const c = x2 * y1 - x1 * y2 const c = x2 * y1 - x1 * y2
return Math.abs(a * x + b * y + c) < 1000 return Math.abs(a * x + b * y + c) < 1000*/
/*/!*const a = line.y2 - line.y1 /*/!*const a = line.y2 - line.y1
const b = line.x1 - line.x2 const b = line.x1 - line.x2
const c = line.x2 * line.y1 - line.x1 * line.y2 const c = line.x2 * line.y1 - line.x1 * line.y2
const result = Math.abs(a * point.x + b * point.y + c) / 100 const result = Math.abs(a * point.x + b * point.y + c) / 100
// 점이 선 위에 있는지 확인 // 점이 선 위에 있는지 확인
return result <= 10*!/ return result <= 10*!*/
// 직선 방정식 만족 여부 확인 // 직선 방정식 만족 여부 확인
const crossProduct = (y - y1) * (x2 - x1) - (x - x1) * (y2 - y1) const crossProduct = (y - y1) * (x2 - x1) - (x - x1) * (y2 - y1)
if (Math.abs(crossProduct) > 10) return false // 작은 오차 허용 if (Math.abs(crossProduct) > 10) return false // 작은 오차 허용
@ -539,7 +539,7 @@ export function isPointOnLine({ x1, y1, x2, y2 }, { x, y }, epsilon = 2) {
const withinXRange = Math.min(x1, x2) <= x && x <= Math.max(x1, x2) const withinXRange = Math.min(x1, x2) <= x && x <= Math.max(x1, x2)
const withinYRange = Math.min(y1, y2) <= y && y <= Math.max(y1, y2) const withinYRange = Math.min(y1, y2) <= y && y <= Math.max(y1, y2)
return withinXRange && withinYRange*/ return withinXRange && withinYRange
} }
/** /**
* 점과 가까운 line 찾기 * 점과 가까운 line 찾기