not exporting circle size comparisons

This commit is contained in:
Ben Cragg 2019-01-29 09:38:24 +00:00
parent 0d5ba92fbe
commit a56f7fa422
2 changed files with 8 additions and 84 deletions

View File

@ -384,16 +384,16 @@ func (c Circle) Contains(u Vec) bool {
return c.Radius >= toCenter.Len()
}
// MaxCircle will return the larger circle based on the radius.
func MaxCircle(c, d Circle) Circle {
// maxCircle will return the larger circle based on the radius.
func maxCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return d
}
return c
}
// MinCircle will return the smaller circle based on the radius.
func MinCircle(c, d Circle) Circle {
// minCircle will return the smaller circle based on the radius.
func minCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return c
}
@ -402,8 +402,8 @@ func MinCircle(c, d Circle) Circle {
// Union returns the minimal Circle which covers both `c` and `d`.
func (c Circle) Union(d Circle) Circle {
biggerC := MaxCircle(c, d)
smallerC := MinCircle(c, d)
biggerC := maxCircle(c, d)
smallerC := minCircle(c, d)
// Get distance between centers
dist := c.Center.To(d.Center).Len()
@ -432,8 +432,8 @@ func (c Circle) Union(d Circle) Circle {
// centers.
func (c Circle) Intersect(d Circle) Circle {
// Check if one of the circles encompasses the other; if so, return that one
biggerC := MaxCircle(c, d)
smallerC := MinCircle(c, d)
biggerC := maxCircle(c, d)
smallerC := minCircle(c, d)
if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius {
return biggerC

View File

@ -493,79 +493,3 @@ func TestCircle_Intersect(t *testing.T) {
})
}
}
func TestMaxCircle(t *testing.T) {
bigCircle := pixel.C(10, pixel.ZV)
smallCircle := pixel.C(1, pixel.ZV)
type args struct {
c pixel.Circle
d pixel.Circle
}
tests := []struct {
name string
args args
want pixel.Circle
}{
{
name: "MaxCircle(): first bigger",
args: args{c: bigCircle, d: smallCircle},
want: bigCircle,
},
{
name: "MaxCircle(): first smaller",
args: args{c: smallCircle, d: bigCircle},
want: bigCircle,
},
{
name: "MaxCircle(): both same size",
args: args{c: smallCircle, d: smallCircle},
want: smallCircle,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := pixel.MaxCircle(tt.args.c, tt.args.d); !reflect.DeepEqual(got, tt.want) {
t.Errorf("MaxCircle() = %v, want %v", got, tt.want)
}
})
}
}
func TestMinCircle(t *testing.T) {
bigCircle := pixel.C(10, pixel.ZV)
smallCircle := pixel.C(1, pixel.ZV)
type args struct {
c pixel.Circle
d pixel.Circle
}
tests := []struct {
name string
args args
want pixel.Circle
}{
{
name: "MinCircle(): first bigger",
args: args{c: bigCircle, d: smallCircle},
want: smallCircle,
},
{
name: "MinCircle(): first smaller",
args: args{c: smallCircle, d: bigCircle},
want: smallCircle,
},
{
name: "MinCircle(): both same size",
args: args{c: smallCircle, d: smallCircle},
want: smallCircle,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := pixel.MinCircle(tt.args.c, tt.args.d); !reflect.DeepEqual(got, tt.want) {
t.Errorf("MinCircle() = %v, want %v", got, tt.want)
}
})
}
}