Suppose that we have a surface f(x,y,z) = s just like the image below (found it randomly):
https://i.stack.imgur.com/YEm90.png
Given a line equation: $$p(k) = p_0+k \cdot r$$
I would like to know how many times does this line intersects with the surface above if the direction vector r is parallel to the x, y, or z axis.
Also, what if the direction vector r is perpendicular to the x, y, or z axis ?
This is how i think of it (out of intuition):
Perpendicular: to x or y then it intersects one time. if it is perpendicular to z, then intersects twice.
Parallel: to x one time, to y two times and finally parallel to z one time.
I am not sure even if this correct, but is there a formal way to say what is what here?
Hint:
Write the equation of the line as: $$ x=p_x+r_x k \qquad y=p_y+r_y k \qquad z=p_z+r_z k $$
The points of intersection of this line with the surface of equation $f(x,y,z)=s$ are such that $f(p_x+r_x k,p_y+r_y k,p_z+r_z k)=s$. This is an equation in the unknown $k$, solve for $k$ and you have the intersection points.
Note that in general this can be an equation very difficult to solve and the number of solutions depends from the function $f$.
From your figure it seems that this function can be put in the form $z=g(x,y)$ and this means that if the line is parallel to the $z$ axis we can have only one common point.