Given a 3D coordinate system and rectangular prisms with a non-negative starting point and a non-negative size (e.g. starts at (0, 2, 5)
and has a size of (9, 20, 5)
): how can I best check if another rectangular prism intersects with one of the prisms already in the coordinate system? Eventually, the goal would be to perform this check for all prisms present, being able to test one should be sufficient to complete this task.
Info: starting points and sizes are 3-tuples of non-negative longs. I am looking for an elegant solution that is moderately fast.
My project is in java, but any math formula, pseudo code or description is more than enough.