normalising before getting bigger/smaller

This commit is contained in:
Ben Cragg 2019-01-29 11:33:12 +00:00
parent b06a31baa3
commit 44d030b9ca
1 changed files with 4 additions and 4 deletions

View File

@ -415,8 +415,8 @@ func minCircle(c, d Circle) Circle {
// Union returns the minimal Circle which covers both `c` and `d`. // Union returns the minimal Circle which covers both `c` and `d`.
func (c Circle) Union(d Circle) Circle { func (c Circle) Union(d Circle) Circle {
biggerC := maxCircle(c, d) biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c, d) smallerC := minCircle(c.Norm(), d.Norm())
// Get distance between centers // Get distance between centers
dist := c.Center.To(d.Center).Len() dist := c.Center.To(d.Center).Len()
@ -445,8 +445,8 @@ func (c Circle) Union(d Circle) Circle {
// centers. // centers.
func (c Circle) Intersect(d Circle) Circle { func (c Circle) Intersect(d Circle) Circle {
// Check if one of the circles encompasses the other; if so, return that one // Check if one of the circles encompasses the other; if so, return that one
biggerC := maxCircle(c, d) biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c, d) smallerC := minCircle(c.Norm(), d.Norm())
if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius { if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius {
return biggerC return biggerC