1

I have a 3D non-degenerate triangle, with a front and back determined by vertex winding. This triangle, together with a depth d, describes a right triangular prism* (the back of the triangle is "inside", and the other triangular face is defined implicitly).

Given a fourth point, I need to check if that point is within the prism, and, if so, find the closest point to it on the surface of the given triangular face.

Notes:

  • This question is similar, but not quite what I want.
  • *not necessarily with a right triangular face.
Community
  • 1
  • 1
geometrian
  • 14,775
  • 10
  • 56
  • 132

1 Answers1

1

Using the answer in https://stackoverflow.com/a/8361714/15472 to find if a point is over a triangle, you can first check to see if it is over the bottom triangle, then if it is under the top triangle (reverse winding here), and if both are true, you now know that it lies in between. The closest point is either its projection on the top or its projection on the bottom. That is, if you know how to solve How can I find out if point is within a triangle in 3D?, you can solve this one easily.

It may be more computationally efficient to make a rotation so that you get a 2D problem; check to see if the (now single) triangle contains the point, and rotate again to check for distances to each of the two projections.

Community
  • 1
  • 1
tucuxi
  • 17,561
  • 2
  • 43
  • 74