Algorithm for checking if 3D point inside convex polyhedron (square pyramid)

后端 未结 2 2031
既然无缘
既然无缘 2021-01-16 21:42

I am looking robust collision detection algorithms and found an awesome book called Realtime Collision Detection by Christer Ericson. I am trying to use a p

相关标签:
2条回答
  • 2021-01-16 21:57

    here's a similar question

    Basically your shape is a polyhedron but that is simply defined as a shape with many faces normally 6. You need to actually be looking for the name tetrahedron which is the classic pyramid shape you have defined in the visual representation above. But the basic answer is taking the normal of your 5 planes (the 4 triangles and one square), and check if they are facing in the same direction of the point in space. If they all return false then your point is inside of the shape. If any one of them returns true then you are outside the shape. This type of test works for most convex shapes because there is no case where the planes are overlapping there normals.

    0 讨论(0)
  • 2021-01-16 22:00

    I would say that you understood the most of it. I'm not sure what exactly you mean with "distance". Usually the dotproduct provides the angle between the two vectors. In your case there's one position vector (the point) and one normal vector. Because of the laws of cosine, if the dotproduct is greater 0, the angle between the two vectors is less than 90 degrees. On the other hand, if the product is negative, the angle is greater than 90 degrees. If it's 0, the vectors are orthogonal. So basically it's got nothing to do with distance, but with angles.

    0 讨论(0)
提交回复
热议问题