Home | Computer Graphics | Adventures in Ray Tracing |     Share This Page

All content Copyright © 2005, P. Lutus. All rights reserved.

Click me for 3D
Click above image for 3D ()

Constructive Solid Geometry
We now turn to one of the more powerful abilities built into POV-Ray, constructive solid geometry (hereafter CSG). CSG is to three-dimensional graphics as a milling machine is to a block of metal — you can use the machine to turn the metal into any number of interesting shapes.

If you have acquired a modeling program, and if the modeling program is worthwhile, it will have a list of geometric shapes to choose among in an efficient way. KPovModeler has such a list of geometric solids that can be placed in a developing scene with a click of the mouse. For this sort of complex example I highly recommend a modeling program.

Since I have been building lenses for some prior examples, let's start by asking how we might use CSG to build a lens. Click below to access the example listings that build our lens:

Click Me
Click this image repeatedly to see the changes
described in the text
Click Me
Click this image to replay the animation
As the reader can see by examining these listings, the first two examples combine two spheres using the CSG operator "union". This means the resulting geometric object is a simple combination of the two original objects. Then, in step 3, the CSG operator is changed to "intersection", meaning the resulting object is composed only of those parts of the original two objects that intersect, or overlap. This, along with some essential internal specifications already covered (like an "interior" with a specified refraction), gives us a perfectly serviceable double-convex lens.

Now click the first of the two graphic images on this page repeatedly to see the progression through examples 1 through 5. Notice the progression, starting with two overlapping spheres, then the change to properties typical of glass (transparent, with an internal index of refraction), then to the "intersection" of the two spheres, then showing light passing through the resulting object as it would through a lens.

Now click the second graphic on this page. It's an animation, a feature of POV-Ray we have not discussed yet (listing here, notice the line including the work "clock"). The animation shows that the lens is actually behaving itself as a real lens wold — convex lenses have a specific focal length, a point at which the departing waveforont converges, one can see that clearly in this example.

As usual, I have covered only the simplest example of CSG, hoping you will visit the POV-Ray documentation site for more depth, read the documentation and see the examples that are provided with POV-Ray, and that you will experiment on your own with this powerful property of POV-Ray.

 

Home | Computer Graphics | Adventures in Ray Tracing |     Share This Page