0

2 cubic objects in a 3-dimensional space is capable to determine if they intersect

· If the cubes intersect determine what the volume of the shared space is.

· The two cubes are parallel to each other (they are not rotated in any way).

· To build each of the cubes the user must be able to provide coordinates (x,y,z) for the center of the cube and the length of the edge.

Sample Data

Cube A: Length of the edge = 5m, center point (x = 10m, y = 10m, z = 0)

Cube B: Length of the edge = 2m, center point (x = 9m, y = 9m, z = 0)

The cubes intersect and the intersection volume is 8.0 m³

  • Question about your statement "The two cubes are parallel to each other (they are not rotated in any way)." Does this mean that the two cubes are aligned with the x, y, and z axes? If so, it makes the problem MUCH easier; as a hint, the volume of intersection will either be empty or it will be an axis-aligned rectangular solid whose axis lengths can be easily determined. It may help to think of the problem in 2D (two squares) and draw a picture. – Mark Lavin Oct 21 '21 at 15:14
  • 1
    You could start by looking at the 1D version: how to check whether two line segments overlap? Then, start looking how to extend this to a 2D version. [Building Collision Simulations: An Introduction to Computer Graphics](https://www.youtube.com/watch?v=eED4bSkYCB8) could be a nice introduction. – JohanC Oct 21 '21 at 15:46
  • What 3D library and language are you using? In javascript/THREE.js you have tools to help you. Here is another stack overflow question answering your question https://stackoverflow.com/questions/11473755/how-to-detect-collision-in-three-js – Justin Meskan Oct 21 '21 at 20:54
  • Can you explain the how sample data resulting the cubes intersect and the intersection volume is 8.0 m³ ? by giving the centre point and edge ? – Prameela Oct 22 '21 at 11:16

0 Answers0