• Advertisement

Archived

This topic is now archived and is closed to further replies.

Point position detection

This topic is 5432 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

Which is the faster metod to determine if a point is inside a polygon after I have verify than the point belong to the polygon''s plane ?? Thanks

Share this post


Link to post
Share on other sites
Advertisement
''Faster'' is debatable, an easy way is to use the cross product test:


  
bool TestPtInFace(const std::vector<Point3>& pts,const Point3& pt,const Vector3& normal)
{
int ptCount = pts.size();

for(int i=0;i<ptCount;i++)
{
Vector3 edge = pts[(i+1)%ptCount] - pts[i];

if(Dot( Cross( edge, pt - pts[i] ),normal ) < 0)
return false;
}
return true;
}


Some say the barycentric method is better, others that some other way is better. At least the above code should work even if it''s not optimal.

Share this post


Link to post
Share on other sites
Would i be entirely wrong if i said that you should be able to dot the point with all three vertices of the triangle, and add the results together? If the result is 180 degrees it''s inside...
Something like that atleast ;P

--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites

  • Advertisement