TITLE: Calculating Intersections of Lines and Algebraic Surfaces
QUESTION [5 upvotes]: For context I am developing a ray-tracer for a computer science class, and want to implement some more advanced shapes than just spheres.  So while this is related to schoolwork, I'm not asking you to do my work for me, the work is implementing the programming, and it's the math I don't understand, so I'm just looking for help understanding how the math works.
I am trying to understand how to calculate the intersection point, and the normal vector from that point, of several algebraic surfaces.  I am at the very frustrating point of knowing what I need to do, and how it is theoretically done, but not really grasping how to actually do it.
I know that I need to take the equation for the line and substitute the x, y, and z variables in the surface equation for the equivalent portions of the line equation, but as soon as I sit down to do that, I immediately hit a mental brick wall.  As for the normal calculations, I'm really lost, I'm not even sure there is a general case way to calculate the normals.
So, I'd love some help on how to calculate the intersection and normal of some of these shapes, and any sort of general case rules for these calculations would be fantastic.
Update
While real general case solutions would be super awesome, it's ok to assume the shapes are in their standard orientation, not rotated or transformed at all - just positioned and (maybe) scaled. This make the problem much simpler, I believe. If there are other limitations you can use to make the problem even simpler, that's likely fine.

REPLY [12 votes]: Perhaps this more elementary description could help.
Let $e$ be the eye/camera, and $v$ a line-of-sight vector.
You want to solve simultaneously $e + t v$ with the surface you want to view, solving for $t$.
If you have two or more surfaces, don't try to intersect them with one another,
which can be algebraically complex, but rather let the ray tracing (effectively) do it for you.
Suppose you have a surface patch $S$ (perhaps a Bezier surface) parametrized by $a$ and $b$.
So now you want to solve simultaneously for $(t, a, b)$.  If $S$ is a sphere or cylinder,
this amounts to quadratic equations.  If $S$ is a cubic patch, it will reduce to solving
cubic equations.  If $S$ is a torus, degree-4 equations. Once you have $(a,b)$, you can get the normal vector at that point from your parametric equations, as
J.M. describes.