bp3d icon indicating copy to clipboard operation
bp3d copied to clipboard

is intersect --> rectIntersect necessary?

Open nabsul opened this issue 8 years ago • 0 comments

Is it my imagination, or is the use of this function redundant? Instead of doing all combinations of two dimensions, why not just do all three dims at the same time? Or one dimension at a time?

func rectIntersect(i1, i2 *Item, x, y Axis) bool {
	d1 := i1.GetDimension()
	d2 := i2.GetDimension()

	cx1 := i1.Position[x] + d1[x]/2
	cy1 := i1.Position[y] + d1[y]/2
	cx2 := i2.Position[x] + d2[x]/2
	cy2 := i2.Position[y] + d2[y]/2

	ix := math.Max(cx1, cx2) - math.Min(cx1, cx2)
	iy := math.Max(cy1, cy2) - math.Min(cy1, cy2)

	return ix < (d1[x]+d2[x])/2 && iy < (d1[y]+d2[y])/2
}

nabsul avatar Feb 25 '17 15:02 nabsul