diff --git a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx index e08bc839..e4807c36 100644 --- a/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx +++ b/src/components/floor-plan/modal/dimensionLine/DimensionLineSetting.jsx @@ -9,7 +9,7 @@ import { canvasState, pitchTextSelector } from '@/store/canvasAtom' import { defaultSlope } from '@/store/commonAtom' import { re } from 'mathjs' import { basicSettingState } from '@/store/settingAtom' -import { getChonByDegree } from '@/util/canvas-util' +import { getChonByDegree, getDegreeByChon } from '@/util/canvas-util' export default function DimensionLineSetting(props) { const contextPopupPosition = useRecoilValue(contextPopupPositionState) @@ -106,14 +106,14 @@ export default function DimensionLineSetting(props) { } const calculateLength = (originalLength, angle, angle1) => { - const slope1 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle) : angle - const slope2 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle1 ?? 0) : angle1 if (!angle1) { - const angleInRadians = slope1 * (Math.PI / 180) - const result = Math.sqrt(Math.pow(originalLength * Math.tan(angleInRadians), 2) + Math.pow(originalLength, 2)) - console.log(angleInRadians, result) + const slope1 = basicSetting.roofAngleSet !== 'slope' ? getDegreeByChon(angle) : angle + const result = Math.sqrt(Math.pow(originalLength * Math.tan((getDegreeByChon(slope1) * Math.PI) / 180), 2) + Math.pow(originalLength, 2)) + console.log(result) return result } else { + const slope1 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle) : angle + const slope2 = basicSetting.roofAngleSet !== 'slope' ? getChonByDegree(angle1 ?? 0) : angle1 const numerator = Math.sqrt(Math.pow(slope1, 2) + 100 + Math.pow((10 * slope1) / slope2, 2)) * originalLength const denominator = Math.sqrt(Math.pow((10 * slope1) / slope2, 2) + 100) const result = numerator / denominator