From 010b34f5fb89d5ad2b02a844750e8060d8173c0a Mon Sep 17 00:00:00 2001 From: "hyojun.choi" Date: Thu, 20 Feb 2025 16:32:54 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B0=9C=EC=A0=84=20=EC=8B=9C=EB=AE=AC?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EC=85=98=20=EA=B0=81=EB=8F=84=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/module/useTrestle.js | 66 +++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/hooks/module/useTrestle.js b/src/hooks/module/useTrestle.js index 248568b5..17f58814 100644 --- a/src/hooks/module/useTrestle.js +++ b/src/hooks/module/useTrestle.js @@ -710,7 +710,7 @@ export const useTrestle = () => { slope, classType: currentAngleType === 'slope' ? '0' : '1', angle: getDegreeByChon(slope), - azimuth: surfaceCompass ?? moduleCompass ?? 0, + azimuth: getAzimuth(surface), moduleList, } }) @@ -726,6 +726,70 @@ export const useTrestle = () => { return { itemList, northArrangement, roofSurfaceList, circuitItemList } } + const getAzimuth = (surface) => { + const { moduleCompass, surfaceCompass, direction } = surface + + if (surfaceCompass) { + if (surfaceCompass > 180) { + return surfaceCompass - 360 + } + return surfaceCompass + } + + switch (direction) { + case 'south': { + if (moduleCompass < 0) { + return -1 * moduleCompass + } else if (moduleCompass === 0) { + return 0 + } else if (moduleCompass < 180) { + return -1 * moduleCompass + } else if (moduleCompass === 180) { + return 180 + } + } + case 'north': { + if (moduleCompass < 0) { + return -1 * (180 + moduleCompass) + } else if (moduleCompass === 0) { + return 180 + } else if (moduleCompass < 180) { + return 180 - moduleCompass + } else if (moduleCompass === 180) { + return 0 + } + } + case 'west': { + if (moduleCompass > -180 && moduleCompass < -90) { + return -180 - (90 + moduleCompass) + } else if (moduleCompass < 0) { + return 180 - (90 + moduleCompass) + } else if (moduleCompass === 0) { + return 90 + } else if (moduleCompass < 180) { + return 90 - moduleCompass + } else if (moduleCompass === 180) { + return -90 + } + } + case 'east': { + if (moduleCompass < 0) { + return -(90 + moduleCompass) + } else if (moduleCompass === 0) { + return -90 + } else if (moduleCompass < 90) { + return -180 + (90 - moduleCompass) + } else if (moduleCompass < 180) { + return 180 + (90 - moduleCompass) + } else if (moduleCompass === 180) { + return 90 + } + } + } + + return 0 + } + const getNorthArrangement = () => { const surfaces = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE_SETUP_SURFACE) let northArrangement = '0'