Given a point in 3D space of the form (x, y, z) and a triangle consisting of 3 vectors (also in the (x, y, z) format), how would I calculate the minimum distance between the point and the face of the triangle?
I understand it involves the normal of the plane that the triangle lies on however I'm unsure how to calculate the plane and then the magnitude of the plane's normal, to the point.
Thanks for any help!
without going into all the gory detail, maybe i can outline one approach to the problem which may assist you in developing your own understanding of the situation. the method can also easily be applied to a hyperplane in a higher-dimensional space.
if your vectors are $v_1, v_2, v_3$ then a point in the plane determined by their endpoints must have the form $$ \alpha v_1 + \beta v_2 + \gamma v_3$$
with the additional condition that
$$ \alpha + \beta +\gamma = 1$$
the square of the distance of a vector's endpoint from the origin is given by the scalar product of the vector with itself. we can attempt therefore to minimize this squared distance. using Lagrange's technique, we attempt to find a value of $\lambda$ so that the three derivatives of the expression:
$$ L(\lambda) = (\alpha v_1 + \beta v_2 + \gamma v_3)^2 - \lambda(\alpha + \beta +\gamma) $$
with respect to $\alpha, \beta, \gamma $ all vanish. the squaring here signifies a scalar product, so it is convenient to introduce the constants $k_{ij}$ where $$ k_{ij} = v_i . v_j$$
now $$ \frac{\partial L}{\partial \alpha} = 2v_1 . (\alpha v_1 + \beta v_2 + \gamma v_3) - \lambda \\ = 2(k_{11} \alpha + k_{12} \beta + k_{13} \gamma) - \lambda $$ setting this equal to zero, and likewise for the other two partial derivatives, then together with the condition $ \alpha + \beta +\gamma = 1$ this will give you a system of four linear equations in the four unknowns $\alpha, \beta, \gamma$ and $\lambda$, and solving this system will give you the coordinates of the point where the normal drawn through the origin meets the plane determined by the vertices of your triangle.