update
This commit is contained in:
@@ -11,7 +11,7 @@ export default class MathUtils {
|
||||
public static distance(x1: number, y1: number, x2: number, y2: number) {
|
||||
// 设两点A(X1,Y1),B(X2,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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user