🐛 增加 GenerateCircle 传入圆的半径和需要的点数量,生成一个圆

This commit is contained in:
kercylan 2023-06-18 14:03:05 +08:00
parent 68144afa3e
commit 7dd059556d
3 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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))
}

View File

@ -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
}