Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Point in vertex defined box algorithm?

How would I test if a point is within a 3D box that is defined by its 8 points only or by its 6 quads? (Dont have access to normal vectors)

The box is made up of triangles, but the two polygons on each side are aligned so could be considered a quad.

like image 618
ashleysmithgpu Avatar asked Apr 26 '26 08:04

ashleysmithgpu


1 Answers

You can test that by forming 6 square pyramids with your point as head and 4 vertices of a each quad as base, then summing up volumes of square pyramids. If sum of volumes is equal to volume of your box, the point is in the box. If sum of volumes is greater than your box's volume, it's outside of the box (sum of volumes would never be less than box volume).

For calculating volume of each square pyramid, you can break it into two tetrahedrons where their volume could be easily calculated by a mix vector product. You can calculate volume of box with mix vector product as well.

like image 152
saeedn Avatar answered Apr 28 '26 21:04

saeedn