if it’s such a specific case I assume it’s a classic homework.

this is a particular case that requires no complex point cloud reconstruction into an object, because 4 non co-planar points can only form one solid (since you haven’t been given any more info you can only create an explicitly faceted object), which is a pyramid with a triangular base, where every point is connected to all other points.

```
all you need to do is resolve it into 4 triangles.
```

take an arbitrary point (let’s say 1), calculate a triangle connecting that to 2 and 3, calculate another triangle connecting it to 3 and 4 and then create the last triangle from all points except the first (2, 3 and 4).

once you have these 3 triangles and the point you want to check for presence inside the object,cast a random ray from the point (in this case a ray will be just a vector starting from that point and of near infinite magnitude) and check this ray for intersection against all triangles.

```
if this ray intersects once the point is inside the object, if it intersects 0 or twice it's outside.
```

also remember to perform particular cases checks making sure the point isn’t sitting exactly on a vertex, on a triangle or that your random ray isn’t traveling exactly through one or more vertices.

also, for the sake of implementation and flooring the magnitude of the ray vector, the ray vector you use can be of a magnitude equal to the distance between the point you are checking and the furthest of the 4 vertices forming the solid (plus something for the sake of particular cases)

```
if you're not familiar with rays here's a comparison of several ray2triangle algorithms
[http://wscg.zcu.cz/wscg2001/Papers_2001/R75.pdf](http://wscg.zcu.cz/wscg2001/Papers_2001/R75.pdf)
```

edit:

almost forgot, if you also want normals on these triangles, for the sake of defining inside and outside in shading problems and not just in intersection problems, you can always calculate the normal finding the perpendicular to each triangle and sitting a normalized vector on it orienting it so that it points AWAY from the only point not in that triangle.

gotta love particular cases