Two axis-aligned boxes overlap when they overlap on both axes, and the shallowest of those overlaps tells you which way to push them apart. Today you build that test.
Detect overlap between two axis-aligned boxes and return the minimum-penetration axis as the manifold.
Two axis-aligned boxes overlap only if they overlap on both the x and y axes at
once - if there is any gap on either axis, they are apart. On each axis the overlap is
min(maxes) - max(mins); a non-positive result on either axis means no collision. This
is the Separating Axis Theorem in its simplest form, specialized to the two axes a box
is aligned with.
When they do overlap, the box wants to be pushed out the cheapest way - along the
axis with the smaller overlap, because that is the shortest move that separates them.
That shallower overlap is the penetration, and the normal points along that axis from A
toward B (compare the box centers to pick the sign). Here the x overlap is 1 and the y
overlap is 2, so the boxes separate along x with penetration 1. Choosing the minimum
axis is the same idea you will generalize to arbitrary polygons with full SAT.
func AABBvsAABB(a, b AABB) Manifold {// overlap on each axis: min(maxes) - max(mins)ox := math.Min(a.Max.X, b.Max.X) - math.Max(a.Min.X, b.Min.X)oy := math.Min(a.Max.Y, b.Max.Y) - math.Max(a.Min.Y, b.Min.Y)if ox <= 0 || oy <= 0 { return Manifold{} } // separated on some axis// pick the smaller overlap as the axis; normal points A -> B along it}