# Intersection of a ray and a curved surface

• Aug 30th 2010, 10:07 AM
posix_memalign
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 $ray(t) = (5, -1, 0)^T + t(-1, 1, 1)^T$ intersects the curved surface $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.
• Aug 30th 2010, 10:45 AM
Failure
Quote:

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 $ray(t) = (5, -1, 0)^T + t(-1, 1, 1)^T$ intersects the curved surface $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.

Quote:

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.
• Aug 30th 2010, 10:45 AM
mfetch22
I agree