#1526 보조선 이용해서 할당 시 길이 계산 안되는 현상 수정
This commit is contained in:
parent
69f0c5a8b2
commit
516d3b32a1
@ -1023,6 +1023,9 @@ export const usePolygon = () => {
|
||||
const line = divideLines[i]
|
||||
const { intersections, startPoint, endPoint } = line
|
||||
|
||||
// 원본 라인의 기하학적 길이 (비율 계산용)
|
||||
const originalGeomLength = Math.round(Math.hypot(line.x2 - line.x1, line.y2 - line.y1)) * 10
|
||||
|
||||
if (intersections.length === 1) {
|
||||
const newLinePoint1 = [line.x1, line.y1, intersections[0].x, intersections[0].y]
|
||||
const newLinePoint2 = [intersections[0].x, intersections[0].y, line.x2, line.y2]
|
||||
@ -1042,25 +1045,43 @@ export const usePolygon = () => {
|
||||
name: 'newLine',
|
||||
})
|
||||
|
||||
// 두 라인 중 큰 길이로 통일
|
||||
// 분할된 각 세그먼트의 기하학적 길이
|
||||
const length1 = Math.round(Math.hypot(newLine1.x1 - newLine1.x2, newLine1.y1 - newLine1.y2)) * 10
|
||||
const length2 = Math.round(Math.hypot(newLine2.x1 - newLine2.x2, newLine2.y1 - newLine2.y2)) * 10
|
||||
const maxLength = Math.max(length1, length2)
|
||||
const unifiedPlaneSize = line.attributes.planeSize ?? maxLength
|
||||
const unifiedActualSize = line.attributes.actualSize ?? maxLength
|
||||
|
||||
// 원본에 planeSize/actualSize가 있으면 비율로 분배, 없으면 기하학적 길이 사용
|
||||
let planeSize1, planeSize2, actualSize1, actualSize2
|
||||
if (line.attributes.planeSize && originalGeomLength > 0) {
|
||||
const ratio1 = length1 / originalGeomLength
|
||||
const ratio2 = length2 / originalGeomLength
|
||||
planeSize1 = Math.round(line.attributes.planeSize * ratio1)
|
||||
planeSize2 = Math.round(line.attributes.planeSize * ratio2)
|
||||
} else {
|
||||
planeSize1 = length1
|
||||
planeSize2 = length2
|
||||
}
|
||||
if (line.attributes.actualSize && originalGeomLength > 0) {
|
||||
const ratio1 = length1 / originalGeomLength
|
||||
const ratio2 = length2 / originalGeomLength
|
||||
actualSize1 = Math.round(line.attributes.actualSize * ratio1)
|
||||
actualSize2 = Math.round(line.attributes.actualSize * ratio2)
|
||||
} else {
|
||||
actualSize1 = length1
|
||||
actualSize2 = length2
|
||||
}
|
||||
|
||||
newLine1.attributes = {
|
||||
...line.attributes,
|
||||
planeSize: unifiedPlaneSize,
|
||||
actualSize: unifiedActualSize,
|
||||
planeSize: planeSize1,
|
||||
actualSize: actualSize1,
|
||||
}
|
||||
newLine1.length = maxLength
|
||||
newLine1.length = length1
|
||||
newLine2.attributes = {
|
||||
...line.attributes,
|
||||
planeSize: unifiedPlaneSize,
|
||||
actualSize: unifiedActualSize,
|
||||
planeSize: planeSize2,
|
||||
actualSize: actualSize2,
|
||||
}
|
||||
newLine2.length = maxLength
|
||||
newLine2.length = length2
|
||||
|
||||
newLines.push(newLine1, newLine2)
|
||||
divideLines.splice(i, 1) // 기존 line 제거
|
||||
@ -1080,12 +1101,25 @@ export const usePolygon = () => {
|
||||
})
|
||||
|
||||
const calcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10
|
||||
|
||||
let segPlaneSize, segActualSize
|
||||
if (line.attributes.planeSize && originalGeomLength > 0) {
|
||||
segPlaneSize = Math.round(line.attributes.planeSize * (calcLength / originalGeomLength))
|
||||
} else {
|
||||
segPlaneSize = calcLength
|
||||
}
|
||||
if (line.attributes.actualSize && originalGeomLength > 0) {
|
||||
segActualSize = Math.round(line.attributes.actualSize * (calcLength / originalGeomLength))
|
||||
} else {
|
||||
segActualSize = calcLength
|
||||
}
|
||||
|
||||
newLine.attributes = {
|
||||
...line.attributes,
|
||||
planeSize: line.attributes.planeSize ?? calcLength,
|
||||
actualSize: line.attributes.actualSize ?? calcLength,
|
||||
planeSize: segPlaneSize,
|
||||
actualSize: segActualSize,
|
||||
}
|
||||
newLine.length = line.attributes.planeSize ?? calcLength
|
||||
newLine.length = calcLength
|
||||
|
||||
newLines.push(newLine)
|
||||
currentPoint = minDistancePoint
|
||||
@ -1100,12 +1134,25 @@ export const usePolygon = () => {
|
||||
name: 'newLine',
|
||||
})
|
||||
const lastCalcLength = Math.round(Math.hypot(newLine.x1 - newLine.x2, newLine.y1 - newLine.y2)) * 10
|
||||
|
||||
let lastPlaneSize, lastActualSize
|
||||
if (line.attributes.planeSize && originalGeomLength > 0) {
|
||||
lastPlaneSize = Math.round(line.attributes.planeSize * (lastCalcLength / originalGeomLength))
|
||||
} else {
|
||||
lastPlaneSize = lastCalcLength
|
||||
}
|
||||
if (line.attributes.actualSize && originalGeomLength > 0) {
|
||||
lastActualSize = Math.round(line.attributes.actualSize * (lastCalcLength / originalGeomLength))
|
||||
} else {
|
||||
lastActualSize = lastCalcLength
|
||||
}
|
||||
|
||||
newLine.attributes = {
|
||||
...line.attributes,
|
||||
planeSize: line.attributes.planeSize ?? lastCalcLength,
|
||||
actualSize: line.attributes.actualSize ?? lastCalcLength,
|
||||
planeSize: lastPlaneSize,
|
||||
actualSize: lastActualSize,
|
||||
}
|
||||
newLine.length = line.attributes.planeSize ?? lastCalcLength
|
||||
newLine.length = lastCalcLength
|
||||
|
||||
newLines.push(newLine)
|
||||
divideLines.splice(i, 1) // 기존 line 제거
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user