title: How can I find out if point is within a triangle in 3D?
body: <p>I need an algorithm (3D), which would determine if point belongs to a triangle. And also if it does I want to know the distance between some point in triangle and a another point. Triangles can be slightly rotated, but if point is outside triangles vertical reach then it should not be considered as inside the triangle.</p>
  
  <p>Now I realize, my question probably doesn't make a lot of sense so here's the picture, which explains what I want.</p>
  
  <p><img src="https://i.stack.imgur.com/qb2iF.png" alt="enter image description here"></p>
  
  <p>Grey lines display, which way triangle is actually facing.</p>
  
  <hr>
  
  <p>It's not actually that I want to check if a point is within a prism, but I after i find out if point lies within triangle (not exactly, might be on top of or below) then I need to find the distance between point and a triangle it belongs to. And depending on the distance function will finally return if that point is inside the triangle. A little inaccuracy is allowed. However, maybe I want to check if a point is within a prism, but do not know that. I am just horrible at math so I am not aware of correct terminology.</p>