Fix BoundingRect

This commit is contained in:
Josh Deprez 2021-09-15 21:36:52 +10:00
parent 261e1a8ac0
commit 77eef2f756

View file

@ -72,12 +72,9 @@ func (b Box) Canon() Box {
} }
// BoundingRect returns an image.Rectangle that bounds the box if it were // BoundingRect returns an image.Rectangle that bounds the box if it were
// projected, i.e. Rectangle{Min: π(Min), Max: π(Max)}. // projected.
func (b Box) BoundingRect(π IntProjection) image.Rectangle { func (b Box) BoundingRect(π IntProjection) image.Rectangle {
return image.Rectangle{ return b.Back(π).Union(b.Front(π))
Min: π.Project(b.Min),
Max: π.Project(b.Max),
}
} }
// Back returns an image.Rectangle representing the back of the box, using // Back returns an image.Rectangle representing the back of the box, using