I have a set of 3D points (I'll call them "outer" points) and a 2D point ("inner" point).
I need to quickly calculate a "good" third coordinate for the inner point so that it would place the constructed 3D point as "close" to the outer points as possible. "Close" may be defined as a minimum sum of distances between the inner 3D point and the outer points or as a sum of differences in the Z-coordinates - I'm open to interpretations to make calculation faster.
My real-world problem is that I need to calculate elevation of way points inside tunnel based on their 2D-coordinates. A tunnel structure has a few (typically 2 but sometimes more) entry and exit points (my "outer" points) where I know not just latitude and longitude but also elevations. Based on this information I need to estimate elevation of points inside the tunnel.
The task is trivial for 1-3 entry points but I don't know how to approach it efficiently for more than 3 outer points.
Well, without knowing much more about the general problem the best I can do is probably what you already know, but I will show it anyway.
Given three entry or exit points $(x_1,y_1,z_1),\,(x_2,y_2,z_2),\,(x_3,y_3,z_3)$ first find the $\textbf{normal vector}$ of the plane containing them by taking the cross product of the two vectors $\langle x_2-x_1,y_2-y_1,z_2-z_1 \rangle$ and $\langle x_3-x_1,y_3-y_1,z_3-z_1 \rangle$ and call that cross-product vector $\langle a,b,c\rangle$.
Then the equation of the plane containing the three points is
\begin{equation} ax+by+cz=ax_1+by_1+cz_1 \end{equation}
For a way point $w=(w_1,w_2,w_3)$ one can compute the estimated value of the elevation $w_3$ by solving the following equation for $w_3$:
\begin{equation} aw_1+bw_2+cw_3=ax_1+by_1+cz_1 \end{equation}
I would pick sets of three maximally separated points for $(x_1,y_1,z_1),\,(x_2,y_2,z_2),\,(x_3,y_3,z_3)$ and if some other outer points were close to some of these three, swap that point out for one close to it and recompute $w_3$. Do this for any two points close together and take an average of the results.