apprenda take home assessment

Derek McQuay 2b69fc7511 added vendor dir for future use 6 months ago
cmd/recty 0f44030e53 updated the readme and cmd/recty/main.go 11 months ago
vendor 2b69fc7511 added vendor dir for future use 6 months ago
.gitignore 56f8910a4e updated gitignore for swp files 11 months ago
LICENSE f672f94faa initial commit 11 months ago
README.md 0f44030e53 updated the readme and cmd/recty/main.go 11 months ago
doc.go a35e73ee10 added doc.go 11 months ago
line.go f88623a1e0 adding corrections for spelling and golint 11 months ago
line_test.go 634cd011c0 ran gofmt -s 11 months ago
point.go ecc870943e added documentation for all functions 11 months ago
point_test.go 634cd011c0 ran gofmt -s 11 months ago
rectangle.go 634cd011c0 ran gofmt -s 11 months ago
rectangle_test.go 634cd011c0 ran gofmt -s 11 months ago
triangle.go ecc870943e added documentation for all functions 11 months ago
triangle_test.go 634cd011c0 ran gofmt -s 11 months ago

README.md

rect

GoDoc Go Report Card

Package rect implements rectangles and can determine when rectangles intersect, are contained, and when rectangles lie adjacent

usage

in cmd/recty/main.go is an example of how one could use this package.

r := rect.Rectangle{     
    P1: rect.Point{1, 1},
    P2: rect.Point{1, 2},
    P3: rect.Point{2, 1},
    P4: rect.Point{2, 2},
}                        

defines a rectangle.

fmt.Println(r.IsRect())

would varify that the rectangle provided is a valid rectangle.

r1 := rect.Rectangle{     
    P1: rect.Point{1, 1},
    P2: rect.Point{1, 2},
    P3: rect.Point{2, 1},
    P4: rect.Point{2, 2},
}                        
r2 := rect.Rectangle{     
    P1: rect.Point{1, 1},
    P2: rect.Point{1, 2},
    P3: rect.Point{2, 1},
    P4: rect.Point{2, 2},
}                        

fmt.Println(rect.Intersection(r1, r2))

Running the above code would print out all intersection points of the two rectangles.

r3 := rect.Rectangle{     
    P1: rect.Point{0, 0},
    P2: rect.Point{0, 3},
    P3: rect.Point{3, 0},
    P4: rect.Point{3, 3},
}                        
r4 := rect.Rectangle{     
    P1: rect.Point{2, 2},
    P2: rect.Point{2, 3},
    P3: rect.Point{3, 2},
    P4: rect.Point{3, 3},
}                        

fmt.Println(rect.Adjacency(r3, r4))

This would return a boolean for whether r3 and r4 have an adjacent side.

r5 := rect.Rectangle{     
    P1: rect.Point{0, 0},
    P2: rect.Point{0, 3},
    P3: rect.Point{3, 0},
    P4: rect.Point{3, 3},
}                        
r6 := rect.Rectangle{     
    P1: rect.Point{1, 1},
    P2: rect.Point{1, 2},
    P3: rect.Point{2, 1},
    P4: rect.Point{2, 2},
}                        

fmt.Println(rect.Containment(r5, r6))

And finally, running rect.Containment(r5, r6) would return true because r6 is contained inside of r5