How do you project points from a quadrilateral-faced hexahedron onto an axis-aligned cuboid that encompasses it?

61 Views Asked by At

I'm using an r-tree to store axis-aligned cuboids for efficient querying. Currently, the comparison algorithms only allow you to use other axis-aligned cuboids (represented by $\min(x_0,y_0,z_0)$, $\max(x_1,y_1,z_1)$ for example) as an input.

I'd like to be able to query the r-tree (EDIT: for overlapping, containment, etc.) with any quadrilateral-faced hexahedron. My idea is to:

  • Create an axis-aligned cuboid that encompasses the space by finding the minimum and maximum of the vertices' dimensions.
  • Query the r-tree with that, generate results.
  • Generate a spatial transformation from the original quad-faced hexahedron to the encompassing cuboid.
  • Apply that transformation to the points of cuboid query results, and then query that set with the encompassing cuboid.
  • All final results should be as if I queried the original r-tree with the quad-faced hexahedron.

The third step is what I'm having a little difficulty with. I assume it'll be a $4\times4$ matrix to transform the points in the space of the hexahedron to the cuboid- there's a lot of literature on projection matrices to get from frustum to cube for screen space transformations that do something similar.

So the question is- what's the easiest way to get my points from quad-faced hexahedron space to an encompassing, axis-aligned cuboid space?