steveb@cbmvax.UUCP (Steve Beats) (06/29/88)
Graphics gurus, I've recently been playing with a simple ray tracing program and would like to increase the number of types of objects it can handle. Currently, I can form images from spheres, disks and arbitrary polygons but I would like to start using things like cones, toroids, cylinders and the like. Unfortunately, my geometry skills leave a lot to be desired and I'm having difficulty finding any books that present the formulae in the manner I need. I've figured out most of the basic stuff from various Siggraph proceedings and the few books I do have but I'm pretty much stuck now. I can generate some good looking scenes with the stuff I have, but the object type limitations are a bit of a pain in the butt. So, what I would like from you folks, if at all possible, are the various formulae for intersecting a ray with different objects. All of my intersect routines (IntersectSphere, IntersectPlane and IntersectDisk) take a pointer to the object to be tested for intersection and a pointer to a ray which consists of an origin and a unit direction vector. Each of the routines returns a distance from the origin of the ray to the point of intersection. If some kind soul(s) could possibly provide me with any formulas you know of to intersect with different objects in this manner I would be much obliged. eg. The sphere intersection formula is; Distance = (Y.W) - sqrt( R^2 - |Y-W(Y.W)|^2 ) Y = a vector from the ray origin to the center of the sphere W = the unit direction vector of the ray R = the radius of the sphere The sphere is specified as an x,y,z point in space and a radius. Oh yes, I also need the method for calculating the surface normal at the point of intersection on a given type of object. The plane is easy because simply normalising a,b and c of the plane equation yields the surface normal directly (I actually store this with the surface description). The sphere is similarily trivial since normalising the vector from the sphere center to the point of intersection also generates the surface normal. If you don't have this information, no problem, I can probably figure it out somehow. Since these kind of request usually (hopefully :-) generate quite a lot of replies, I will be happy to take them as EMail and summarise to the net. Steve