촌 계산 추가, type검사 수정

This commit is contained in:
hyojun.choi 2024-07-11 08:17:17 +09:00
parent 051ea87861
commit 68cb952b70
2 changed files with 16 additions and 2 deletions

View File

@ -81,7 +81,7 @@ export default class QPolygon extends fabric.Group {
})
this.getObjects().forEach((obj) => {
if (obj.type === 'QLine') {
if (obj.type[0] === 'Q') {
obj.setFontSize(fontSize)
}
})

View File

@ -222,8 +222,16 @@ export const getRoofHypotenuse = (base) => {
return Math.sqrt(base * base * 2)
}
/**
* 촌을 입력받아 각도를 반환
* @param chon
* @returns {number}
*/
export const getDegreeByChon = (chon) => {
return chon * 5.45
// tan(theta) = height / base
const radians = Math.atan(chon / 10)
// 라디안을 도 단위로 변환
return Number((radians * (180 / Math.PI)).toFixed(2))
}
/**
@ -265,6 +273,12 @@ export const getDirectionByPoint = (a, b) => {
}
}
/**
* line을 두개를 이용해서 교차점을 찾는 함수
* @param line1
* @param line2
* @returns {{x: number, y: number}|null}
*/
export function calculateIntersection(line1, line2) {
const x1 = line1.x1,
y1 = line1.y1,