Click here to Skip to main content
15,895,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a polyhedron with n-side (x1, y1, z1),...., (xn, yn, zn) and a point P(x, y, z). How to determine P is inside or outside the polyhedron? Thanks.
Posted

1 solution

I would break it into two problems.

1. Is the point inside the bounding sphere of the polyhedron, this is a pretty common hit test and will give you very good results. Typically this would be sufficient for any kind of simulation or game since the accuracy of the hit test actually increases with the number of sides.

2. If you really need to know if the point itself then you need to treat it as any other polygon. Typically this involves casting a ray in any direction and counting the number of intersections. If the point is inside the polygon it will only intersect once (regular polyhedrons are not concave), and if its outside it will intersect zero or twice. If the polyhedron is of a type that is concave (like Star Polyhedrons) then this becomes much harder to determine.

If you search google for "Point in Polyhedron" it will give you a number of articles, and things like this StackOverflow answer[^] that may give you what you need.
 
Share this answer
 
v2
Comments
Andrewpeter 22-Jan-14 23:33pm    
Thanks you! It's great advice, I am trying to do this. My vote is 5.
Ron Beyer 22-Jan-14 23:36pm    
Good luck!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900