adding corrections for spelling and golint
This commit is contained in:
parent
ecc870943e
commit
f88623a1e0
2
line.go
2
line.go
@ -10,7 +10,7 @@ type line struct {
|
||||
pt1, pt2 Point
|
||||
}
|
||||
|
||||
// determinants aids by calculating necesary values for performing
|
||||
// determinants aids by calculating necessary values for performing
|
||||
// calculations using the determinant of two points
|
||||
func determinants(l line) (float64, float64, float64) {
|
||||
a := l.pt2.Y - l.pt1.Y
|
||||
|
22
rectangle.go
22
rectangle.go
@ -70,17 +70,17 @@ func (r Rectangle) size() float64 {
|
||||
// pts[3] -- pts[1], and pts[3] -- pts[2]
|
||||
func (r Rectangle) inOrder() []Point {
|
||||
n1, n2 := r.neighbors(r.P1)
|
||||
accross := &Point{}
|
||||
across := &Point{}
|
||||
if r.P2 != n1 || r.P2 != n2 {
|
||||
accross = &r.P2
|
||||
across = &r.P2
|
||||
}
|
||||
if r.P3 != n1 || r.P3 != n2 {
|
||||
accross = &r.P3
|
||||
across = &r.P3
|
||||
}
|
||||
if r.P4 != n1 || r.P4 != n2 {
|
||||
accross = &r.P4
|
||||
across = &r.P4
|
||||
}
|
||||
return []Point{r.P1, n1, n2, *accross}
|
||||
return []Point{r.P1, n1, n2, *across}
|
||||
}
|
||||
|
||||
// Adjacency detects whether two rectangles, r1, and r2, are adjacent.
|
||||
@ -151,23 +151,23 @@ func Intersection(r1, r2 Rectangle) []Point {
|
||||
func sumOfTri(r Rectangle, p Point) bool {
|
||||
n1, n2 := r.neighbors(r.P1)
|
||||
x1, x2 := Point{}, Point{}
|
||||
accross := &Point{}
|
||||
across := &Point{}
|
||||
if r.P2 != n1 || r.P2 != n2 {
|
||||
accross = &r.P2
|
||||
across = &r.P2
|
||||
x1, x2 = r.neighbors(r.P2)
|
||||
}
|
||||
if r.P3 != n1 || r.P3 != n2 {
|
||||
accross = &r.P3
|
||||
across = &r.P3
|
||||
x1, x2 = r.neighbors(r.P3)
|
||||
}
|
||||
if r.P4 != n1 || r.P4 != n2 {
|
||||
accross = &r.P4
|
||||
across = &r.P4
|
||||
x1, x2 = r.neighbors(r.P4)
|
||||
}
|
||||
sumTri := sizeTriangle(r.P1, n1, p) +
|
||||
sizeTriangle(r.P1, n2, p) +
|
||||
sizeTriangle(*accross, x1, p) +
|
||||
sizeTriangle(*accross, x2, p)
|
||||
sizeTriangle(*across, x1, p) +
|
||||
sizeTriangle(*across, x2, p)
|
||||
if math.Abs(r.size()-sumTri) < ɛ {
|
||||
return true
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func TestIntersection(t *testing.T) {
|
||||
)
|
||||
continue
|
||||
}
|
||||
for i, _ := range actual {
|
||||
for i := range actual {
|
||||
if actual[i] != rt.expected[i] {
|
||||
t.Errorf(
|
||||
"failed intersection:\n\texpected: %v\n\t actual: %v",
|
||||
|
Loading…
Reference in New Issue
Block a user