Calculate if 3D points is between a list of 3D points

Is there a way to calculate if a 3D point is between a list of 3D points?

Here I drew a pyramid.
Circled in blue there is a point.
With Python I try to detect if a the blue circled 3D point is inside the list of 3D points (the list of 3D points, the corners of the pyramid, act as a boundary).

I just want to learn if this could work. Theoretically it could work by allowing a maximum distance of the blue circled 3D points to the list of 3D points. But, I cannot figure it out.
It tried some ways but I cannot find the right way to do it.

Do you might know something about ‘allowing a maximum distance to each point’ like ‘letting everything of the list of 3D points pretending being a boundary?’

problem prism (11.7 KB)

Yes, I know there is a component called ‘points inside breps’ but I want to try it this way and want to know if it is possible.

i’m afraid this won’t work. Using distance, you can’t never be sure if you are inside or outside your figure.

If you build panels on your figure, you can orientate the panels (normal points outside). Then you can project your point on nearest panel. Having the second point you can check if the vector from this two points has the same direction as the panel normal.

Cheers, Raul

You could get the convex hull of the points and see if the point to check is inside the hull curve using point containment.

I don’t know if 3D ConvexHull belongs to a plugin or if it’s “native”, but as Helvetosaur says, this works:

// Rolf

It’s in the “mesh” section.

Yes, but some plugins insert components into the “native” categories, and one cannot (easily) tell from the component itself where it comes from. :frowning:

// Rolf

Well, from my experience, ConvexHull has beeen in GH more or less since it was EH…

My real script is only based on numbers and list of numbers representing coordinates of points.

With python I am searching for mathematical solutions to gain time. It takes hours (about exaggerated) to calculate everything with grasshopper geometries. With more than 2563 points I build everything in coordinates (list of numbers).

Is there really not a way to do things with points?It is like ‘when the testPn is positioned at that place compared to that point,’ by angle ‘there is a maximum allowed distance’ (to all boundary points).

Ah! Maybe I got it.
Or maybe not.
A boundary point measured to every other boundary points forms the maximum distance within a certain angle.

Checking the distance to the testPn comparing it to the maximum distance by angle to a boundary point, it can detect if the point is inside or outside.

This is so hard…

I cannot wrap my brain around it yet (is that the correct English expression?).

Angular distance maximum or something.

ConvexHull and 3D ConvexHull?

If so, I overlooked the 3D version for a long time.

// Rolf

Of course there is. If you know which points form the corners of the pyramid, then you can calculate a plane from three points, say from common corner a, and a-b & a-c forms two legs, from which you can take the cross-product and from that create a plane suing the crossproduct as the plane Normal. The test if the point is always “outside” the planes for all planes.

Edit: Like so (red line is the “crossproduct” vector of ab & ac):

// Rolf

Angle boundaries? Do you know if there is something like that?

When an angle is outside an angle boundary, the testPn is outside.

Well, I think in this case it will be a “false economy”. Even if you have thousands of points a convex hull is very quickly calculated, that is the advantage of that algorithm. Probably much faster than having to check ALL of your points every time. The test for point inclusion in the convex hull might be slower, but still it sounds like you are trying to make this thing more complicated than it is.

For example, I have a convex hull made over 10,000 points in a triangle, that takes 15ms here in GH. If I overlay a random set of 1000 points and then check to see which are in and which are out of the hull, it takes 14ms…

If the test point is “outside” (on the Normal’s side) of all the planes, then the point is not inside the pyramid. (Edit: Just make sure the planes are oriented “outwards” by ordering the legs in the right order to the CrossProduct calculation).

// Rolf

The testPn within a angle-range within a length. 2D it is possible I think. But 3D? That is difficult for me.

Closer to that angle, than the max distance is ‘that,’ closer to another angle than the max is ‘that.’ Taking the average of those things and I have the average length 2D and 3D theoretically.

You can check this link,
It uses thetrahedron but follow the plan system they talk .

They use the “plane” strategy I suggested above. They say

“You now just check if a point P is on the other side of the plane. The normal of each plane is pointing away from the center of the tetrahedron. So you just have to test against 4 planes.”

// Rolf

1 Like

You can make also two thetrahedron :slightly_smiling_face:
The first is :
The second :
And try it on both or = 0 on both

:slight_smile: yes sorry plane

It is part of Mesh Edit plug-in.

1 Like