Shortest distance between a point and a curved triangle I am trying to find a nice formulation on how to calculate the distance between a point $(p_1, p_2, p_3)$ and a triangle in 3D, where the triangle is non flat (Strictly speaking it is not a triangle anymore, but I don't know the correct term for this). The coordinates of all vertices $(v_1, v_2, v_3)$ of the triangle are in the range between zero and one.
To construct the curved triangle from a normal triangle the square root of z from each vertex is calculated and replaces the prior z value:
$v_i[2] = \sqrt{v_i[2]}$
EDIT: Every point on the triangle is also transformed the same way, thus resulting in this curvature.
For flat triangles I have used something similar to this: Distance Between Point and Triangle in 3D.pdf.
I appreciate any help even pointers on how to best tackle this problem are appreciated.
Thanks for your help!
 A: Consider the plane $\pi$ where the vertexes $(v1,v2,v3)$ lie after being transformed. This plane cuts $\mathbb R^3$ in two, and the transformed triangle $\mathbb T$ lies only in one of these parts: that's because all of the triangle's points' coordinates lie in $[0, 1]$ and in this interval we have $\sqrt{z}>z$.
If $P:=(p_1,p_2,p_3)$ happens to be in the half of $\mathbb R^3$ where $\mathbb T$ does not lie, then it's easy to see that the distance $d(P, \mathbb T)$ is equal to $\min(d(P, v_1), d(P, v_2), d(P, v_3))$, that is the minimun of the distances between $P$ and the transformed vertexes.
Whereas if $P$ lies the half where $\mathbb T$ does lie, if there exists a point $Q\in\mathbb T$ such that the vector $P-Q$ is normal to the surface $\mathbb T$, then $d(P, \mathbb T)=d(P, Q)$, otherwise the minimum distance point $Q$ has to lie on the boundary of $\mathbb T$. To choose which edge to check for $Q$ you can use the same partitioning of the article you linked, you'll extend the edges of the triangle $(v1,v2,v3)$ with planes ortogonal to $\pi$.
