Message Boards Message Boards


How to know if a point is in-between 2 3D parallel planes ?

Posted 2 months ago
6 Replies
3 Total Likes


I want to find the easiest way to extract from my list of coordinates points (a pack of nodes of my lattice), those who are located inbetween 2 parallel infinite 3D planes.

I used a cylinder as a thin volume with very a big radius to represent my 2 planes and used Select to extract the points contained inside but I think there is a better and more simple way to do that using maybe the 2 planes equations...

Thanks a lot !

EDIT 1 :

Using the suggestion of Ta'a Nwa Dombou

The variable "bonsnoeuds" contains a list of vectors.

valeur = Abs[
   a (x0up - x0down) + b (y0up - y0down) + c (z0up - z0down)];
bonsnoeuds = 
   Abs[a (#[[1]] - x0up) + b (#[[2]] - y0up) + c (#[[3]] - z0up)] + 
      Abs[a (#[[1]] - x0down) + b (#[[2]] - y0down) + 
        c (#[[3]] - z0down)] == valeur &];

This way is cheaper in time process than using the cylinder method. Also I noticed it is most efficient to use Select 2 times for 2 different conditions rather that overloading Select with multiple condition.

6 Replies

If you represent your parallel planes with equations of the form f[x]=c1 and f[x]=c2 (with the same linear f), a point x lies between the planes exactly when f[x] lies in between the two constants c1,c2.

Posted 2 months ago

Is this method valid in 3D for all kind of planes ?

Welcome to Wolfram Community!
Please make sure you know the rules:
Your post is too vague. Please EDIT your post and describe your subject extensively providing code, details, examples, and other relevant ideas, so it is clear what exactly you are looking for and the relevance to Wolfram Technologies.

Posted 2 months ago

Suppose that the Cartesian equations of your two parallel planes are $$ P_1 : a(x-x_1) + b(y-y_1) + c(z-z_1) = 0, \quad P_2: a(x-x_2)+b(y-y_2) +c(z-z_2) = 0.$$ By using the well-known formula for the distance from a point to a plane , we see that a point (x,y,z) lies between the two planes if and only if $$ |a(x-x_1) + b(y-y_1) + c(z-z_1)| + |a(x-x_2)+b(y-y_2) +c(z-z_2)| \\= |a(x_1-x_2)+b(y_1-y_2) +c(z_1-z_2)| .$$

Posted 2 months ago

Thank you so much. It looks it is working well. Question : does this way includes points that are on the planes or only inbetween ?

Posted 2 months ago

I am glad to know that my suggestion solved your problem. It includes points on the planes. However, you can exclude these points easily: A point is between the two planes if it belongs to neither of the planes and satisfies the the provided equation: $$ a(x-x_1)+ b(y-y_1)+c(z-z_1) \ne 0 \mbox{ and } a(x-x_2)+ b(y-y_2)+c(z-z_2) \ne 0 \mbox{ and } |a(x-x_1)+ b(y-y_1)+c(z-z_1)| + |a(x-x_2)+ b(y-y_2)+c(z-z_2)| =|a(x_1-x_2)+ b(y_1-y_2)+c(z_1-z_2)|. $$ Translating the above expression into Mathematica code is straightforward.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract