Jump to content
  • Advertisement
Sign in to follow this  

Point in Triangular Prism (defined by plane)

This topic is 2504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I check if the projection of a point onto a plane is within a triangle on the plane, without actually projecting it?

In other words, how can I test to check if a point is contained in an infinite triangular prism protruding from a plane, given three points of the plane and the point to be tested:

I've tried something already, using the dot products of each vector, but it didn't seem to work...my code is below:


bool pointintrianglevolume(mlVertex P, mlTriangle t){
mlVertex vec1=t.p[0]-P;
mlVertex vec1a=P-t.p[1];
mlVertex vec2=t.p[1]-P;
mlVertex vec2a=P-t.p[2];
mlVertex vec3=t.p[2]-P;
mlVertex vec3a=P-t.p[0];
return (vec1.dot(vec1a)>=0&&vec2.dot(vec2a)>=0&&vec3.dot(vec3a)>=0);

Share this post

Link to post
Share on other sites
Make sure your plane normals for the prism are all facing in the same direction and then use the dot product. If all dots return > 0 or < 0 they are all on one side of all the planes, and hence within the bounds of the prism. If they all return 0 you are in a dimension other than R3. There is another way that uses pluckers but pluckers you use a ray, not a point.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!