I have a surface which is defined by a list of x and y values with height assigned to them. The continuous surface is built with spline methods so in the end I have the heights of all possible (x,y). I also have a point and unit vector (derived from that point). What I need is to find the point where the line (made from that unit vector) hits my surface. I am having trouble with constructing that line (and I am not sure if that is necessary) and finding the fastest way to get the intersection. Thak you for your help.
EDIT
This is the example of my coordinates and the code that I was advised to write in order to have my surface.
Z=[]
Z.append([20.2, 20.1, 35])
Z.append([20.1, 24.5, 36])
Z.append([21.0, 23.2, 33])
Z.append([22.3, 20.0, 34])
Z.append([22.3, 19.5, 28])
Z.append([20.1, 19.5, 27])
Z.append([20.1, 24.6, 31])
Z.append([22.3, 24.6, 32])
# ---------------------------
xin=np.array(Z)[:,0];
yin=np.array(Z)[:,1];
zin=np.array(Z)[:,2];
# ----------------------------
xout=np.linspace(20.,23.,10);
yout=np.linspace(19.,25.,10);
xout,yout = np.meshgrid(xout,yout);
# ----------------------------
zout=griddata((xin,yin),zin,(xout,yout),'cubic');
# -----------------------------
from pylab import pcolormesh,show
pcolormesh(xout,yout,zout);show();
Lets say I have a point (21.0, 20.0, 60) and it is rotated 9 degrees to north, 2 degrees to east (here 21.0 represents longitude, 20.0 - latitude, 60 - altitude).
Not an easy problem.
As it seems, your interpolant is piecewise, presumably defined over a triangulation (if not, please specify).
If you know the expression of the interpolant, presumably a cubic polynomial, you can determine the range of values taken on every tile (you need to find the stationary points inside, those on the edges and the values at the corners).
This creates a bounding volume for every patch, and the surface is wrapped in vertical, non-overlapping prisms.
Now for a given ray, you project it on the XY plane, and see which prism base it crosses. If the bases are convex polygons, it will cross them along a line segment. For the entry and exit points, compute the Z value (along the ray) and check if there is an overlap with the Z range of the patch.
Finally, when you have found a hit, solve the system formed by the parametric equation of the ray and the explicit equation of the surface. In the case of a cubic surface, this gives a cubic polynomial, for which analytical formulas are available. There can be up to three solutions.
You should trace the ray starting from the source and stop as soon as you have found a solution (if there are several intersections in the same patch, keep the closes to the source).