From 68e456fe8f9366598340359c6a49fa44e4ab59af Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 20 Jun 2023 16:31:23 +0800 Subject: [PATCH] =?UTF-8?q?:boom:=20=E5=90=8D=E7=A7=B0=E7=AE=80=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/components/moving2d.go | 2 +- utils/geometry/geometry.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/component/components/moving2d.go b/component/components/moving2d.go index d6feb4e..3f78555 100644 --- a/component/components/moving2d.go +++ b/component/components/moving2d.go @@ -131,7 +131,7 @@ func (slf *Moving2D) handle() { slf.OnPosition2DDestinationEvent(entity) continue } else { - nx, ny := geometry.CalculateNewCoordinate(x, y, angle, moveDistance) + nx, ny := geometry.CalcNewCoordinate(x, y, angle, moveDistance) entity.SetPosition(nx, ny) entity.lastMoveTime = moveTime slf.OnPosition2DChangeEvent(entity, x, y) diff --git a/utils/geometry/geometry.go b/utils/geometry/geometry.go index d60b7ac..bd3f1f1 100644 --- a/utils/geometry/geometry.go +++ b/utils/geometry/geometry.go @@ -126,8 +126,8 @@ func CalcAngle[V generic.SignedNumber](x1, y1, x2, y2 V) V { return V(math.Atan2(float64(y2-y1), float64(x2-x1)) * 180 / math.Pi) } -// CalculateNewCoordinate 根据给定的x、y坐标、角度和距离计算新的坐标 -func CalculateNewCoordinate[V generic.SignedNumber](x, y, angle, distance V) (newX, newY V) { +// CalcNewCoordinate 根据给定的x、y坐标、角度和距离计算新的坐标 +func CalcNewCoordinate[V generic.SignedNumber](x, y, angle, distance V) (newX, newY V) { // 将角度转换为弧度 var pi = math.Pi var dividend = 180.0