Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions circle.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func (c Circle) Area() float64 {
return math.Pi * math.Pow(c.Radius, 2)
}

// Bounds returns the bounding box for the circle
func (c Circle) Bounds() Rect {
return Rect{
Min: V(c.Center.X-c.Radius, c.Center.Y-c.Radius),
Max: V(c.Center.X+c.Radius, c.Center.Y+c.Radius),
}
}

// Moved returns the Circle moved by the given vector delta.
func (c Circle) Moved(delta Vec) Circle {
return Circle{
Expand Down
5 changes: 5 additions & 0 deletions rectangle.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ func (r Rect) Area() float64 {
return r.W() * r.H()
}

// Bounds returns the bounding box for the rect (itself)
func (r Rect) Bounds() Rect {
return r
}

// Edges will return the four lines which make up the edges of the rectangle.
func (r Rect) Edges() [4]Line {
corners := r.Vertices()
Expand Down