# Thread: Intersection of a ray and a curved surface

1. ## Intersection of a ray and a curved surface

Hi,
I'd like to write a ray tracing program but I have some issues with the mathematics thereof, I'm trying to do some exercises in a book to help me as such but I don't know how to solve e.g. problems of the form:

Find where (if at all) the ray $\displaystyle ray(t) = (5, -1, 0)^T + t(-1, 1, 1)^T$ intersects the curved surface $\displaystyle z(x, y) = (x - 2)(y - 3) + 4$, if there is more than one intersection, which is the first?

As far as I understand I should set the two equations equal to each other and try solve them for the unknown parameter t? I've tried this but I can't get anywhere.

2. Originally Posted by posix_memalign
Hi,
I'd like to write a ray tracing program but I have some issues with the mathematics thereof, I'm trying to do some exercises in a book to help me as such but I don't know how to solve e.g. problems of the form:

Find where (if at all) the ray $\displaystyle ray(t) = (5, -1, 0)^T + t(-1, 1, 1)^T$ intersects the curved surface $\displaystyle z(x, y) = (x - 2)(y - 3) + 4$, if there is more than one intersection, which is the first?
The one that is closer to the source of the ray, of course! For, you see, a ray is not a line: a ray has a source from which it originates. Once a ray hits a surface it gets reflected - and the reflected ray may, in principle, hit the same or another surface at some other point.

As far as I understand I should set the two equations equal to each other and try solve them for the unknown parameter t? I've tried this but I can't get anywhere.
I find that surprising: why, you just replace the coordinates x,y,z in the equation for the surface with terms expressed with t, i.e. x=5-t, y=-1+t and z=t, based on the equation of the ray, then solve for t.
In your example this gives the two solutions t1=2 and t2=4, if I am not mistaken (check it for yourself). Now plug these two values of t back into the equation of the ray and you have found the points of intersection.

3. I agree