diff --git a/src/hooks/module/useModuleBasicSetting.js b/src/hooks/module/useModuleBasicSetting.js index d95cf077..2915b548 100644 --- a/src/hooks/module/useModuleBasicSetting.js +++ b/src/hooks/module/useModuleBasicSetting.js @@ -133,7 +133,7 @@ export function useModuleBasicSetting(tabNum) { const offsetObjects = moduleSelectionData.roofConstructions.find((item) => item.addRoof.index === roofIndex) roof.lines.forEach((line) => { - line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line.attributes.type, roof.pitch, roof.from) } + line.attributes = { ...line.attributes, offset: getOffset(offsetObjects.addRoof, line, roof.pitch, roof.from) } }) //배치면 설치 영역 makeModuleInstArea(roof, detail) @@ -167,7 +167,7 @@ export function useModuleBasicSetting(tabNum) { } } - const getOffset = (data, type, pitch, from = '') => { + const getOffset = (data, line, pitch, from = '') => { const degree = getDegreeByChon(pitch) //각도 // 계산 값 @@ -185,15 +185,24 @@ export function useModuleBasicSetting(tabNum) { return numerator / denominator } + const point1 = { x: line.x1, y: line.y1 } + const point2 = { x: line.x2, y: line.y2 } + let isDiagonal = false // 대각선 있는지 확인 + + const angle = calculateAngle(point1, point2) //선의 각도 계산 + if (!(Math.abs(angle) === 0 || Math.abs(angle) === 180 || Math.abs(angle) === 90)) { + isDiagonal = true + } + //경사 신장률은 1 / cos쎄타 const calculateHeightRate = 1 / Math.cos((degree * Math.PI) / 180) const calculateValue = calculateHeightRate / calculateExpression(degree) const eavesResult = from === 'roofCover' ? (data.eavesMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.eavesMargin / 10 const ridgeResult = from === 'roofCover' ? (data.ridgeMargin * Math.cos((degree * Math.PI) / 180)) / 10 : data.ridgeMargin / 10 - const kerabaMargin = from === 'roofCover' ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10 + const kerabaMargin = from === 'roofCover' && isDiagonal ? data.kerabaMargin / calculateValue / 10 : data.kerabaMargin / 10 - switch (type) { + switch (line.attributes.type) { case LINE_TYPE.WALLLINE.EAVES: return eavesResult case LINE_TYPE.WALLLINE.GABLE: