From 7dd059556d50e14dc0102964954ede3be9c96d68 Mon Sep 17 00:00:00 2001 From: kercylan <61743331+kercylan98@users.noreply.github.com> Date: Sun, 18 Jun 2023 14:03:05 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E5=A2=9E=E5=8A=A0=20GenerateCircle=20?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E5=9C=86=E7=9A=84=E5=8D=8A=E5=BE=84=E5=92=8C?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=E7=82=B9=E6=95=B0=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=80=E4=B8=AA=E5=9C=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/geometry/circle.go | 1 - utils/geometry/circle_test.go | 11 +++++++++++ utils/geometry/shape.go | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 utils/geometry/circle_test.go diff --git a/utils/geometry/circle.go b/utils/geometry/circle.go index b6b1709..8da0aa8 100644 --- a/utils/geometry/circle.go +++ b/utils/geometry/circle.go @@ -13,7 +13,6 @@ func GenerateCircle[V generic.SignedNumber](radius V, points int) Shape[V] { curAngle := float64(i) * angle x := radius * V(math.Cos(curAngle)) y := radius * V(math.Sin(curAngle)) - shape = append(shape, NewPoint(x, y)) } return shape diff --git a/utils/geometry/circle_test.go b/utils/geometry/circle_test.go new file mode 100644 index 0000000..580c767 --- /dev/null +++ b/utils/geometry/circle_test.go @@ -0,0 +1,11 @@ +package geometry_test + +import ( + "fmt" + "github.com/kercylan98/minotaur/utils/geometry" + "testing" +) + +func TestGenerateCircle(t *testing.T) { + fmt.Println(geometry.GenerateCircle[float64](5, 12)) +} diff --git a/utils/geometry/shape.go b/utils/geometry/shape.go index 6af79aa..ef5a051 100644 --- a/utils/geometry/shape.go +++ b/utils/geometry/shape.go @@ -30,7 +30,7 @@ func (slf Shape[V]) String() string { for x := left; x < left+width; x++ { exist := false for _, p := range slf { - if x == p.GetX() && y == p.GetY() { + if int(x) == int(p.GetX()) && int(y) == int(p.GetY()) { exist = true break }