point 각도 계산시 point가 없는 경우에 대한 에러 처리
This commit is contained in:
parent
b789293ae5
commit
7f4f138ada
@ -23,8 +23,12 @@ export const defineQPloygon = () => {
|
|||||||
* @returns {number}
|
* @returns {number}
|
||||||
*/
|
*/
|
||||||
export const calculateAngle = (point1, point2) => {
|
export const calculateAngle = (point1, point2) => {
|
||||||
const deltaX = Big(point2.x).minus(point1.x).toNumber()
|
const deltaX = Big(point2?.x !== undefined ? point2.x : 0)
|
||||||
const deltaY = Big(point2.y).minus(point1.y).toNumber()
|
.minus(point1?.x !== undefined ? point1.x : 0)
|
||||||
|
.toNumber()
|
||||||
|
const deltaY = Big(point2?.y !== undefined ? point2.y : 0)
|
||||||
|
.minus(point1?.y !== undefined ? point1.y : 0)
|
||||||
|
.toNumber()
|
||||||
const angleInRadians = Math.atan2(deltaY, deltaX)
|
const angleInRadians = Math.atan2(deltaY, deltaX)
|
||||||
return angleInRadians * (180 / Math.PI)
|
return angleInRadians * (180 / Math.PI)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user