# Line Intersection with Surface

Suppose that we have a surface f(x,y,z) = s just like the image below (found it randomly):

http://i.imgur.com/JEACguK.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.

• Thanks for your answer! This may sound a bit dumb but I don't quite understand this part: "This is an equation in the unknown k, solve for k and you have the intersection points." Could you perhaps show me a simple example of a simple function in action? – Br. Sptr Aug 17 '16 at 20:03
• As a simple example: let $f(x,y,z)=x^2+y^2+z^2=r^2$ be the surface (a sphere of radius r centered at the origin) and $x=k,y=k,z=0$ the line (a bisector in $xy$ plane), than the equation is: $2k^2=r^2$ with solutions $k=\pm r/\sqrt{2}$. So the two intersection points are $( r/\sqrt{2}, r/\sqrt{2})$ and $( -r/\sqrt{2}, -r/\sqrt{2})$. – Emilio Novati Aug 17 '16 at 20:15

I have a question. Is $z$ the parameter in your line equations. Next, the number of intersections totally depends on your surface. I can tweak the embedding of a sphere in $3$-space and have the intersection be $k$-times for any positive integer $k$.

• Hey, I had mistake in line equation as you noticed, cheers, I corrected it. Exactly, it depends on the surface, that's why I am asking if there is a formal way to do it for any surface given that line and parameters! – Br. Sptr Aug 17 '16 at 18:37