I’m trying to determine if two cubes overlap. I’ve read up on overlapping rectangles, but I’m not sure how to translate it into the third dimension.
My goal is to generate a number of randomly positioned and sized non-overlapping cubes.
These cubes are represented on a x,y,z Cartesian plane.
You should be able to modify Determine if two rectangles overlap each other? to your purpose fairly easily.
Suppose that you have
CubeAandCubeB. Any one of 6 conditions guarantees that no overlap can exist:So the condition for no overlap is:
Therefore, a sufficient condition for Overlap is the opposite (De Morgan)