Right now I'm working on a library for finding the distances between objects in Lua. I've had some trouble finding the distance between a point and a bounded plane. I'm using these parametric equations:
$$ \mbox{plane}(s_0,t) = (x_0, y_0, z_0) + s \le(x_1, y_1, z_1) + t(x_2, y_2, z_2), \quad 0 \le (s_0, t) \le 1 $$
and
$$ \mbox{point}(s_1) = (x_3, y_3, z_3) + s(x_4, y_4, z_4), \quad 0 \le s_1 \le 1 $$
I know that the projection of a line segment from any point on the plane to the point-I-want-to-find-the-distance-from onto the normal of the plane will give me the distance from a point to an unbounded plane.
In an attempt to solve my problem, I said that the point on the plane that is closest to my point is my point plus the inverse of the projection onto the normal. I would then solve the values of s and t to see if they where greater then one. If so, then I would try to find the distance from the 4 points in the plane, and use the line between the two closest points to my point to find the distance between my point and bounded plane. This is very inefficient.
So my question, is there a more direct way to solve the distance between a point and a surface/bounded plane?