So, I would like to find out a function that allows you to determine if two cubes of arbitrary rotation and size intersect.
If the cubes are not arbitrary in their rotation (but tied to a certain axis), the intersection is simple; you check whether they intersect in all three dimensions, checking their boundaries to see if they intersect or are inside each other in all three dimensions. If they intersect or are within only two, they do not intersect. This method can be used to determine if arbitrary cubes are even candidates for intersection, using their highest / lowest x, y and z to create outer borders.
This is the first step. In theory, based on this information, we can determine which side they are from each other, which means that we can eliminate some of the squares (sides) from our intersection. However, I cannot assume that we have this information, since rotating cubes can make it difficult to determine simply.
My idea is to take each pair of ATVs, find the intersection of their planes, and then determine if this line intersects with at least one edge of each of the pairs of sides. If any pair of sides has an intersection line that intersects with any of their edges, then the quadras intersect. If none of them intersect, two cubes do not intersect.
Then we can determine the depth of intersection on the second cube, where the intersection plane intersects its edge (s).
This is just speculative. Is there a better, more efficient way to determine the intersection of these two cubes? I can come up with several different ways to do this, and I can also say that they can be very different in terms of the number of calculations needed.
I work in Java at the moment, but C / C ++ - the solutions are also cool (I can transfer them); even psuedocode, as this is probably a big question.
user1086498
source share