核心原理:四象限,角度弧度转换
getRotation(coordinate) {
const [start, end] = coordinate
const dx = end[0] - start[0]
const dy = end[1] - start[1]
const rotation = Math.atan2(dy, dx)
let rotationText = 0
if (rotation > 0 && rotation < Math.PI / 2) {
rotationText = -rotation
}
if (Math.PI / 2 < rotation && rotation < Math.PI) {
rotationText = Math.PI - rotation
}
if (-Math.PI / 2 < rotation && rotation < 0) {
rotationText = -rotation
}
if (-Math.PI < rotation && rotation < -Math.PI / 2) {
rotationText = Math.PI - rotation
}
return rotationText
}
3861

被折叠的 条评论
为什么被折叠?



