Sign in to follow this  

Point in Triangular Prism (defined by plane)

This topic is 2315 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:

[script]

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);
}
[/script]

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

This topic is 2315 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this