How can I find the volume of intersection of two cubes? And their vertexes?
Hello everyone, how can I find the volume of the intersection of two cubes aligned to the axis?
The cubes can have different sizes and positions.
(I add a picture to show a simple example case of two cubes)
After deep research, I am quite sure that does not exist a specific function in Unity to use for this purpose, the only way to work out this problem is mathematical logic.
For example, my first idea was:
1) To find the 8 vertexes of the cube"intersection" (B in image).
2) Try to build a new cube with this vertex.
3) Find the size and volume of cube "intersection".
Unity permits to find:
the centre of each primary cube (A in the image) with "Bounds.centre";
the extents of each primary cube (A in the image) from the centre of the cube (half of the size of the Bounds) with "Bounds.extents".
documentation avaible here:
https://docs.unity3d.com/ScriptReference/Bounds.html
However, I can't find a way to have the vertex of each cube.
And, secondly, a logical function that can find what 8 of 16 vertexes found are the right vertex to use to build the cube"Intersection".
Have u got any help or suggest?
Image:
Your answer
Follow this Question
Related Questions
Getting intersection points between a plane and an object 0 Answers
Find Intersection Point Two Sphere 0 Answers
Clear intersection Texture 0 Answers
Cursor collision 0 Answers
Player intersecting with ground during jump landing 1 Answer