This commit is contained in:
2024-05-01 19:13:01 +08:00
parent cf008327aa
commit 80a32d9b1b
150 changed files with 8561 additions and 5045 deletions

View File

@@ -11,7 +11,7 @@ export default class MathUtils {
public static distance(x1: number, y1: number, x2: number, y2: number) {
// 设两点AX1,Y1,BX2,Y2
// 距离D=X2-X1的平方+Y2-Y1平方的和开平方
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2))
return Math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
}
/**
@@ -45,7 +45,7 @@ export default class MathUtils {
* @param endP
*/
public static p2pRad(startP: Vec2, endP: Vec2) {
let rad: number = Math.atan2(endP.y - startP.y, endP.x - startP.x)
const rad: number = Math.atan2(endP.y - startP.y, endP.x - startP.x)
return rad
}
@@ -54,11 +54,8 @@ export default class MathUtils {
* @param rot
*/
public static rotation2Fish(rot: number) {
if (rot >= 0 && rot <= 180) {
rot = 180 - rot
} else {
rot = -180 - rot
}
if (rot >= 0 && rot <= 180) rot = 180 - rot
else rot = -180 - rot
return rot
}
}