Check if the point lies within the 3d volume

1.8k Views Asked by At

what is the condition to check if any point(x,y,z) lies within any 3d shape (cuboid, tetrahedrons etc). Is there any generic condition that I can use to compute it for any shape.

2

There are 2 best solutions below

1
On

you can put x0,y0,z0 into function f(x,y,z) so that you get the plane or 'slice' you can determine whether the point lies in the closed curve of the 3d shape in this 2d plane if all 3 satisfies, then it's in the 3d shape

for example, you want to find whether (0,0,0) is in the shape x^2+y^2+z^2=1 you first substitute x = 0 in getting the yOz plane where y^2+z^2 =1 you find (0,0) is in this curve. using the same method, you will find its also in the curve in xOz, xOy plane, so its in the 3d shape

0
On

The difficulty of checking if a point lies inside a given set $S \subset \mathbb{R}^3$ is related to how the set $S$ is defined. If $S$ is defined using a very simple condition, i.e. $S = \{(x,y,z) \mid x > 0\}$, then checking membership is very easy. If $S$ is defined using complicated integrals or limits, it might be very hard to ascertain if a point lies in $S$.

For the shapes you mentioned above, there is a fairly easy algorithm for checking membership. Such polyhedra are (by definition) the intersection of finitely many half-spaces (see picture below). A half-space is a subset of the form $ax + by + cz + d \geq 0$, and is one side of a hyperplane. To check that $(x,y,z)$ is inside a polyhedra, you can check that $(x,y,z)$ satisfies all of the hyperplanes defining the polyhedron. Each such calculation is very simple, and presuming that there aren't too many, this algorithm will be fast.

This isn't the only way to check set membership in computational geometry, but it is a fairly simple one.

enter image description here