From f21c48599f003dd4580768810e7ffba752f009ab Mon Sep 17 00:00:00 2001 From: Ben Cragg Date: Thu, 14 Feb 2019 14:12:05 +0000 Subject: [PATCH] Made naming consistent --- geometry.go | 10 +++++----- geometry_test.go | 32 ++++++++++++++++---------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/geometry.go b/geometry.go index 95ccbf9..8cd49e8 100644 --- a/geometry.go +++ b/geometry.go @@ -318,15 +318,15 @@ func (r Rect) Intersect(s Rect) Rect { return t } -// IntersectsCircle returns a minimal required Vector, such that moving the circle by that vector would stop the Circle +// IntersectCircle returns a minimal required Vector, such that moving the circle by that vector would stop the Circle // and the Rect intersecting. This function returns a zero-vector if the Circle and Rect do not overlap, and if only // the perimeters touch. // // This function will return true if: // - The Rect contains the Circle, partially or fully // - The Circle contains the Rect, partially of fully -func (r Rect) IntersectsCircle(c Circle) Vec { - return c.IntersectsRect(r).Scaled(-1) +func (r Rect) IntersectCircle(c Circle) Vec { + return c.IntersectRect(r).Scaled(-1) } // Circle is a 2D circle. It is defined by two properties: @@ -476,14 +476,14 @@ func (c Circle) Intersect(d Circle) Circle { } } -// IntersectsRect returns a minimal required Vector, such that moving the circle by that vector would stop the Circle +// IntersectRect returns a minimal required Vector, such that moving the circle by that vector would stop the Circle // and the Rect intersecting. This function returns a zero-vector if the Circle and Rect do not overlap, and if only // the perimeters touch. // // This function will return true if: // - The Rect contains the Circle, partially or fully // - The Circle contains the Rect, partially of fully -func (c Circle) IntersectsRect(r Rect) Vec { +func (c Circle) IntersectRect(r Rect) Vec { // h and v will hold the minimum horizontal and vertical distances (respectively) to avoid overlapping var h, v float64 diff --git a/geometry_test.go b/geometry_test.go index da321b2..1ecc58e 100644 --- a/geometry_test.go +++ b/geometry_test.go @@ -541,7 +541,7 @@ func TestCircle_Intersect(t *testing.T) { } } -func TestRect_IntersectsCircle(t *testing.T) { +func TestRect_IntersectCircle(t *testing.T) { type fields struct { Min pixel.Vec Max pixel.Vec @@ -556,79 +556,79 @@ func TestRect_IntersectsCircle(t *testing.T) { want pixel.Vec }{ { - name: "Rect.IntersectsCircle(): no overlap", + name: "Rect.IntersectCircle(): no overlap", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(50, 50), 1)}, want: pixel.ZV, }, { - name: "Rect.IntersectsCircle(): circle contains rect", + name: "Rect.IntersectCircle(): circle contains rect", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(5, 5), 10)}, want: pixel.V(-15, 0), }, { - name: "Rect.IntersectsCircle(): rect contains circle", + name: "Rect.IntersectCircle(): rect contains circle", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(5, 5), 1)}, want: pixel.V(-6, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps bottom-left corner", + name: "Rect.IntersectCircle(): circle overlaps bottom-left corner", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(0, 0), 1)}, want: pixel.V(1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps top-left corner", + name: "Rect.IntersectCircle(): circle overlaps top-left corner", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(0, 10), 1)}, want: pixel.V(1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps bottom-right corner", + name: "Rect.IntersectCircle(): circle overlaps bottom-right corner", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(10, 0), 1)}, want: pixel.V(-1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps top-right corner", + name: "Rect.IntersectCircle(): circle overlaps top-right corner", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(10, 10), 1)}, want: pixel.V(-1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps two corners", + name: "Rect.IntersectCircle(): circle overlaps two corners", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(0, 5), 6)}, want: pixel.V(6, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps left edge", + name: "Rect.IntersectCircle(): circle overlaps left edge", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(0, 5), 1)}, want: pixel.V(1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps bottom edge", + name: "Rect.IntersectCircle(): circle overlaps bottom edge", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(5, 0), 1)}, want: pixel.V(0, 1), }, { - name: "Rect.IntersectsCircle(): circle overlaps right edge", + name: "Rect.IntersectCircle(): circle overlaps right edge", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(10, 5), 1)}, want: pixel.V(-1, 0), }, { - name: "Rect.IntersectsCircle(): circle overlaps top edge", + name: "Rect.IntersectCircle(): circle overlaps top edge", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(5, 10), 1)}, want: pixel.V(0, -1), }, { - name: "Rect.IntersectsCircle(): edge is tangent", + name: "Rect.IntersectCircle(): edge is tangent", fields: fields{Min: pixel.ZV, Max: pixel.V(10, 10)}, args: args{c: pixel.C(pixel.V(-1, 5), 1)}, want: pixel.ZV, @@ -640,8 +640,8 @@ func TestRect_IntersectsCircle(t *testing.T) { Min: tt.fields.Min, Max: tt.fields.Max, } - if got := r.IntersectsCircle(tt.args.c); got != tt.want { - t.Errorf("Rect.IntersectsCircle() = %v, want %v", got, tt.want) + if got := r.IntersectCircle(tt.args.c); got != tt.want { + t.Errorf("Rect.IntersectCircle() = %v, want %v", got, tt.want) } }) }