버그 수정

This commit is contained in:
Jaeyoung Lee 2025-02-09 10:36:17 +09:00
parent 4101a3ede9
commit 84323b2c1d

View File

@ -832,7 +832,10 @@ const drawRidge = (roof, canvas, textMode) => {
.filter((roof) => isInnerLine(prevRoof, currentRoof, nextRoof, roof)) .filter((roof) => isInnerLine(prevRoof, currentRoof, nextRoof, roof))
.forEach((innerRoof) => { .forEach((innerRoof) => {
const vector1 = { x: currentX2.minus(currentX1), y: currentY2.minus(currentY1) } const vector1 = { x: currentX2.minus(currentX1), y: currentY2.minus(currentY1) }
const vector2 = { x: Big(innerRoof.x2).minus(Big(innerRoof.x1)), y: Big(innerRoof.y2).minus(Big(innerRoof.y1)) } const vector2 = {
x: Big(innerRoof.x2).minus(Big(innerRoof.x1)),
y: Big(innerRoof.y2).minus(Big(innerRoof.y1)),
}
const dotProduct = vector1.x.times(vector2.x).plus(vector1.y.times(vector2.y)) const dotProduct = vector1.x.times(vector2.x).plus(vector1.y.times(vector2.y))
const magnitude1 = vector1.x.pow(2).plus(vector1.y.pow(2)).sqrt() const magnitude1 = vector1.x.pow(2).plus(vector1.y.pow(2)).sqrt()
@ -857,7 +860,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt() .sqrt()
.div(10) .div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber()) console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: nextRoof.x1, y1: nextRoof.y1, x2: nextRoof.x2, y2: nextRoof.y2 })) console.log('check ridgeMinLength', calcLinePlaneSize({
x1: nextRoof.x1,
y1: nextRoof.y1,
x2: nextRoof.x2,
y2: nextRoof.y2,
}))
} }
if (currentAngle === 90 || currentAngle === 270) { if (currentAngle === 90 || currentAngle === 270) {
currentY2 = innerRoof.y1 currentY2 = innerRoof.y1
@ -870,7 +878,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt() .sqrt()
.div(10) .div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber()) console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: nextRoof.x1, y1: nextRoof.y1, x2: innerRoof.x2, y2: nextRoof.y2 })) console.log('check ridgeMinLength', calcLinePlaneSize({
x1: nextRoof.x1,
y1: nextRoof.y1,
x2: innerRoof.x2,
y2: nextRoof.y2,
}))
} }
} }
if (Math.abs(currentAngle - ibAngle) === 0) { if (Math.abs(currentAngle - ibAngle) === 0) {
@ -885,7 +898,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt() .sqrt()
.div(10) .div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber()) console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: prevRoof.x1, y1: prevRoof.y1, x2: prevRoof.x2, y2: innerRoof.y1 })) console.log('check ridgeMinLength', calcLinePlaneSize({
x1: prevRoof.x1,
y1: prevRoof.y1,
x2: prevRoof.x2,
y2: innerRoof.y1,
}))
} }
if (currentAngle === 90 || currentAngle === 270) { if (currentAngle === 90 || currentAngle === 270) {
currentY1 = innerRoof.y2 currentY1 = innerRoof.y2
@ -898,7 +916,12 @@ const drawRidge = (roof, canvas, textMode) => {
.sqrt() .sqrt()
.div(10) .div(10)
console.log('ridgeMinLength : ', ridgeMinLength.toNumber()) console.log('ridgeMinLength : ', ridgeMinLength.toNumber())
console.log('check ridgeMinLength', calcLinePlaneSize({ x1: prevRoof.x1, y1: prevRoof.y1, x2: innerRoof.x2, y2: prevRoof.y2 })) console.log('check ridgeMinLength', calcLinePlaneSize({
x1: prevRoof.x1,
y1: prevRoof.y1,
x2: innerRoof.x2,
y2: prevRoof.y2,
}))
} }
} }
} }
@ -1005,10 +1028,20 @@ const drawRidge = (roof, canvas, textMode) => {
// 시작점에서 종료점까지의 평면길이 // 시작점에서 종료점까지의 평면길이
//startXPoint.minus(endXPoint).abs().pow(2).plus(startYPoint.minus(endYPoint).abs().pow(2)).sqrt() //startXPoint.minus(endXPoint).abs().pow(2).plus(startYPoint.minus(endYPoint).abs().pow(2)).sqrt()
const hypo = Big( const hypo = Big(
calcLinePlaneSize({ x1: startXPoint.toNumber(), y1: startYPoint.toNumber(), x2: endXPoint.toNumber(), y2: endYPoint.toNumber() }), calcLinePlaneSize({
x1: startXPoint.toNumber(),
y1: startYPoint.toNumber(),
x2: endXPoint.toNumber(),
y2: endYPoint.toNumber(),
}),
).div(10) ).div(10)
// 현재 지붕선과 마주하는 지붕선을 잇는 선분의 교차점까지의 길이 // 현재 지붕선과 마주하는 지붕선을 잇는 선분의 교차점까지의 길이
const intersectLength = Big(calcLinePlaneSize({ x1: midX.toNumber(), y1: midY.toNumber(), x2: intersectLine.x, y2: intersectLine.y })).div(10) const intersectLength = Big(calcLinePlaneSize({
x1: midX.toNumber(),
y1: midY.toNumber(),
x2: intersectLine.x,
y2: intersectLine.y,
})).div(10)
//마주하는 지붕선까지의 길이가 현재 지붕선의 이전, 다음 지붕선의 길이보다 작을때 //마주하는 지붕선까지의 길이가 현재 지붕선의 이전, 다음 지붕선의 길이보다 작을때
if (intersectLength.lt(Big(prevRoof.attributes.planeSize).div(10)) && intersectLength.lt(Big(nextRoof.attributes.planeSize).div(10))) { if (intersectLength.lt(Big(prevRoof.attributes.planeSize).div(10)) && intersectLength.lt(Big(nextRoof.attributes.planeSize).div(10))) {
endXPoint = startXPoint endXPoint = startXPoint
@ -1190,10 +1223,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }), planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}),
actualSize: actualSize:
prevDegree === currentDegree prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }, currentDegree) ? calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}, currentDegree)
: 0, : 0,
}, },
}) })
@ -1215,10 +1258,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }), planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}),
actualSize: actualSize:
prevDegree === currentDegree prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: ridgeCoordinate.x1, y2: ridgeCoordinate.y1 }, currentDegree) ? calcLineActualSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: ridgeCoordinate.x1,
y2: ridgeCoordinate.y1,
}, currentDegree)
: 0, : 0,
}, },
}) })
@ -1293,10 +1346,20 @@ const drawHips = (roof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgePoints.x, y2: ridgePoints.y }), planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgePoints.x,
y2: ridgePoints.y,
}),
actualSize: actualSize:
prevDegree === currentDegree prevDegree === currentDegree
? calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: ridgePoints.x, y2: ridgePoints.y }, currentDegree) ? calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: ridgePoints.x,
y2: ridgePoints.y,
}, currentDegree)
: 0, : 0,
}, },
}) })
@ -1691,7 +1754,7 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
const midX = Big(currentRoof.x1).plus(Big(currentRoof.x2)).div(2) // 지붕의 X 중심 const midX = Big(currentRoof.x1).plus(Big(currentRoof.x2)).div(2) // 지붕의 X 중심
const midY = Big(currentRoof.y1).plus(Big(currentRoof.y2)).div(2) // 지붕의 Y 중심 const midY = Big(currentRoof.y1).plus(Big(currentRoof.y2)).div(2) // 지붕의 Y 중심
const midWallX = Big(wallLine.x1).plus(wallLine.x).div(2) const midWallX = Big(wallLine.x1).plus(Big(wallLine.x2)).div(2)
const midWallY = Big(wallLine.y1).plus(Big(wallLine.y2)).div(2) // 벽의 Y 중심 const midWallY = Big(wallLine.y1).plus(Big(wallLine.y2)).div(2) // 벽의 Y 중심
const alpha = midX.minus(midWallX) // 벽과 지붕의 X 거리 const alpha = midX.minus(midWallX) // 벽과 지붕의 X 거리
const beta = midY.minus(midWallY) // 벽과 지붕의 Y 거리 const beta = midY.minus(midWallY) // 벽과 지붕의 Y 거리
@ -1817,7 +1880,12 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: hipX2.toNumber(), y2: hipY2.toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
}),
actualSize: actualSize:
prevDegree === currentDegree prevDegree === currentDegree
? calcLineActualSize( ? calcLineActualSize(
@ -1840,7 +1908,12 @@ const changeEavesRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: hipX2.toNumber(), y2: hipY2.toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
}),
actualSize: actualSize:
currentDegree === nextDegree currentDegree === nextDegree
? calcLineActualSize( ? calcLineActualSize(
@ -1996,8 +2069,18 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roofId, roofId: roofId,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.toNumber(), y2: midY.toNumber() }), planeSize: calcLinePlaneSize({
actualSize: calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.toNumber(), y2: midY.toNumber() }, Big(90 - prevDegree)), x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.toNumber(),
y2: midY.toNumber(),
}),
actualSize: calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.toNumber(),
y2: midY.toNumber(),
}, Big(90 - prevDegree)),
}, },
}) })
canvas?.add(hip1) canvas?.add(hip1)
@ -2016,7 +2099,12 @@ const changeGableRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roofId, roofId: roofId,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.toNumber(), y2: midY.toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.toNumber(),
y2: midY.toNumber(),
}),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.toNumber(), y2: midY.toNumber() }, { x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.toNumber(), y2: midY.toNumber() },
Big(90 - nextDegree).toNumber(), Big(90 - nextDegree).toNumber(),
@ -2213,9 +2301,19 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
}),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }, {
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
},
Big(90 - prevDegree).toNumber(), Big(90 - prevDegree).toNumber(),
), ),
}, },
@ -2238,9 +2336,19 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
}),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: midX.plus(hipX2).toNumber(), y2: midY.plus(hipY2).toNumber() }, {
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: midX.plus(hipX2).toNumber(),
y2: midY.plus(hipY2).toNumber(),
},
Big(90 - nextDegree).toNumber(), Big(90 - nextDegree).toNumber(),
), ),
}, },
@ -2286,7 +2394,12 @@ const changeHipAndGableRoof = (currentRoof, canvas, textMode) => {
y2: currentRoof.attributes.ridgeCoordinate.y1, y2: currentRoof.attributes.ridgeCoordinate.y1,
}), }),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: hip.x2, y1: hip.y2, x2: currentRoof.attributes.ridgeCoordinate.x1, y2: currentRoof.attributes.ridgeCoordinate.y1 }, {
x1: hip.x2,
y1: hip.y2,
x2: currentRoof.attributes.ridgeCoordinate.x1,
y2: currentRoof.attributes.ridgeCoordinate.y1,
},
Big(90 - gableDegree).toNumber(), Big(90 - gableDegree).toNumber(),
), ),
}, },
@ -2505,7 +2618,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
y2: hipY2.toNumber(), y2: hipY2.toNumber(),
}), }),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: midX.plus(hipX1).toNumber(), y1: midY.plus(hipY1).toNumber(), x2: hipX2.toNumber(), y2: hipY2.toNumber() }, {
x1: midX.plus(hipX1).toNumber(),
y1: midY.plus(hipY1).toNumber(),
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
},
Big(90 - gableDegree).toNumber(), Big(90 - gableDegree).toNumber(),
), ),
}, },
@ -2537,7 +2655,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
y2: hipY2.toNumber(), y2: hipY2.toNumber(),
}), }),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: midX.plus(hipX1).toNumber(), y1: midY.plus(hipY1).toNumber(), x2: hipX2.toNumber(), y2: hipY2.toNumber() }, {
x1: midX.plus(hipX1).toNumber(),
y1: midY.plus(hipY1).toNumber(),
x2: hipX2.toNumber(),
y2: hipY2.toNumber(),
},
Big(90 - gableDegree).toNumber(), Big(90 - gableDegree).toNumber(),
), ),
}, },
@ -2581,7 +2704,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: gable1.x1, y2: gable1.y1 }), planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: gable1.x1, y2: gable1.y1 }),
actualSize: calcLineActualSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: gable1.x1, y2: gable1.y1 }, Big(90 - prevDegree).toNumber()), actualSize: calcLineActualSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: gable1.x1,
y2: gable1.y1,
}, Big(90 - prevDegree).toNumber()),
}, },
}) })
// const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10 // const hip1Base = ((Math.abs(hip1.x1 - hip1.x2) + Math.abs(hip1.y1 - hip1.y2)) / 2) * 10
@ -2603,7 +2731,12 @@ const changeJerkInHeadRoof = (currentRoof, canvas, textMode) => {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: gable2.x1, y2: gable2.y1 }), planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: gable2.x1, y2: gable2.y1 }),
actualSize: calcLineActualSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: gable2.x1, y2: gable2.y1 }, Big(90 - nextDegree).toNumber()), actualSize: calcLineActualSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: gable2.x1,
y2: gable2.y1,
}, Big(90 - nextDegree).toNumber()),
}, },
}) })
// const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10 // const hip2Base = ((Math.abs(hip2.x1 - hip2.x2) + Math.abs(hip2.y1 - hip2.y2)) / 2) * 10
@ -2912,7 +3045,12 @@ const changeWallRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x1, y1: currentRoof.y1, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x1,
y1: currentRoof.y1,
x2: wallMidX.toNumber(),
y2: wallMidY.toNumber(),
}),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: currentRoof.x1, y1: currentRoof.y1, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }, { x1: currentRoof.x1, y1: currentRoof.y1, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() },
Big(90 - prevDegree).toNumber(), Big(90 - prevDegree).toNumber(),
@ -2933,7 +3071,12 @@ const changeWallRoof = (currentRoof, canvas, textMode) => {
attributes: { attributes: {
roofId: roof.id, roofId: roof.id,
currentRoofId: currentRoof.id, currentRoofId: currentRoof.id,
planeSize: calcLinePlaneSize({ x1: currentRoof.x2, y1: currentRoof.y2, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }), planeSize: calcLinePlaneSize({
x1: currentRoof.x2,
y1: currentRoof.y2,
x2: wallMidX.toNumber(),
y2: wallMidY.toNumber(),
}),
actualSize: calcLineActualSize( actualSize: calcLineActualSize(
{ x1: currentRoof.x2, y1: currentRoof.y2, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() }, { x1: currentRoof.x2, y1: currentRoof.y2, x2: wallMidX.toNumber(), y2: wallMidY.toNumber() },
Big(90 - nextDegree).toNumber(), Big(90 - nextDegree).toNumber(),