I'm trying to identify the most efficient way to test if two cells\voxels are connected. I'll discuss the issue in 2 dimensions for simplicity and consider the cells in the diagram...
Now I'll just confine the problem to the vertical axis, call it the y-axis.
The bottom left corner of each cell is its co-ordinate, and it is always a positive integer (if this helps).
The y-axis bounds of A and B can be written,
A.y1 = 4
A.y2 = 8
B.y1 = 7
B.y2 = 8
Now what's the most efficient way to test if A and B are connected/overlap on the y-axis? Note that it should also work if you switch the A and B labels in the diagram around.
Here's my no doubt naive attempt...
IF B.x2 == A.x1
IF (A.y1 <= B.y1) AND (A.y2 >= B.y2) THEN
connected = true
ELSE
IF (A.y1 >= B.y1) AND (A.y2 <= B.y2) THEN
connected = true
ELSE
connected = false
END
END