Removed Diameter function
This commit is contained in:
parent
4c6d061455
commit
b06a31baa3
|
@ -366,14 +366,9 @@ func (c Circle) Norm() Circle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diameter returns the diameter of the Circle.
|
|
||||||
func (c Circle) Diameter() float64 {
|
|
||||||
return c.Radius * 2
|
|
||||||
}
|
|
||||||
|
|
||||||
// Area returns the area of the Circle.
|
// Area returns the area of the Circle.
|
||||||
func (c Circle) Area() float64 {
|
func (c Circle) Area() float64 {
|
||||||
return math.Pi * c.Diameter()
|
return math.Pi * c.Radius * 2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Moved returns the Circle moved by the given vector delta.
|
// Moved returns the Circle moved by the given vector delta.
|
||||||
|
|
|
@ -275,42 +275,6 @@ func TestCircle_Norm(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCircle_Diameter(t *testing.T) {
|
|
||||||
type fields struct {
|
|
||||||
radius float64
|
|
||||||
center pixel.Vec
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
fields fields
|
|
||||||
want float64
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Circle.Diameter(): positive radius",
|
|
||||||
fields: fields{radius: 10, center: pixel.V(0, 0)},
|
|
||||||
want: 20,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Circle.Diameter(): zero radius",
|
|
||||||
fields: fields{radius: 0, center: pixel.V(0, 0)},
|
|
||||||
want: 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Circle.Diameter(): negative radius",
|
|
||||||
fields: fields{radius: -5, center: pixel.V(0, 0)},
|
|
||||||
want: -10,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
c := pixel.C(tt.fields.radius, tt.fields.center)
|
|
||||||
if got := c.Diameter(); got != tt.want {
|
|
||||||
t.Errorf("Circle.Diameter() = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCircle_Area(t *testing.T) {
|
func TestCircle_Area(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
radius float64
|
radius float64
|
||||||
|
|
Loading…
Reference in New Issue