🐛 增加 GenerateCircle 传入圆的半径和需要的点数量,生成一个圆
This commit is contained in:
parent
68144afa3e
commit
7dd059556d
|
@ -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
|
||||
|
|
|
@ -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))
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue