Index |
Raytracing |
Tutorials |
Gallery |
Source Files |
Links |
There are two different methods for creating spirals in POV-ray. It can be useful and easy to use the rotate function in POV, but sometimes the mathematical functions sine and cosine (sin() and cos()) are better suited, especially when using multiple translations. In any case, using variable translations or rotations inside a #while loop does the trick.
Usually spiral (or helix) shapes in POV are really collections of large numbers of spheres or cylinders. By placing these closely together (or in a blob shape) the illusion of one solid object can be created. Particularly when using reflective surfaces, the amount of shapes needed to create a smooth looking surface can be enormous. Therefore, it can be very useful to build in a precision variable for every #while loop, so that test renders don't need much time for parsing.
Before starting with some example objects, I will set the used camera, light sources, textures and object declarations, so that I only need to show the used loop for every example:
camera { location <0,2,-10> look_at <0,0,0> }Now I'll add a loop as a union object to the scene with a built-in precision variable and T as the loop counter. I've chosen a low precision on purpose, so that the separate objects are still visible.
| Step 1 | |
|
#declare Precision = 0.5; union { #declare T = 0; #while (T<360) object { C translate <0,T/180,-2> rotate 4*y*T } #local T = T + 1/Precision; #end rotate x*-20 } |
![]() |
As you might have noticed, this loop uses rotate for the circular shape. I've chosen the domain of T from 0 to 360 (= one full rotation in degrees) on purpose: the number in the rotation (4) now shows the number of full rotations in the loop. The loop is included in a union group, so that the complete group can be translated or rotated again.
translate <0,T/180,-2> sets the starting point of the rotation at <0,0,-2>, rotating up clockwise to y=2 (360/180). The same effect is much more complicated to achieve using sine and cosine.
Using spheres instead of cylinders and setting the Precision to 6 (the number of objects increases from 360 to 2160!), the spiral gets a smooth look:
| Step 2 | |
|
union { #declare Precision = 6; #declare T = 0; #while (T<360) object { S translate <0,T/180,-2> rotate 4*y*T } #local T = T + 1/Precision; #end rotate x*-20 } |
![]() |
You might have noticed that the previous example spirals were pretty 'tight': there was no space between the layers, because 4 rotations were done using spheres with a diameter of 0.5 over a path of 2 units high (and 4*0.5=2). In the next example, the shape has loosened up by increasing the y-path to 3 (360/120) and lowering the number of rotations to 3. In addition, the image shows a bubble look, due to the low precision factor.
| Step 3 | |
|
union { #declare Precision = 0.5; #declare T = 0; #while (T<360) object { S translate <0,T/120,-2> rotate 3*y*T } #local T = T + 1/Precision; #end rotate x*-20 } |
![]() |
The basic usage of #while loops for spiral shapes should be clear now. If it's not, please let me know. Here follow three more interesting examples. The source shows how these images were made.
![]() | ![]() | ![]() |
The interesting thing about the objects above is that they use multiple rotations inside the union statement. To keep things simple, I've separated the translations and rotations into steps (as in the second object - S, S2, S3). The last of the three maybe doesn't look like it has much to do with spirals, but it does show other possibilities for multiple rotations and translations.
I hope this short tutorial gives a clear view of how to make spirals and other shapes consisting of multiple objects. For any questions that I haven't answered on this page or comments on the contents, please don't hesitate to contact me.
You can download the complete tutorial including images and source for off line reading. The files have been compressed into a zip file, so decompression software is needed. Contact me if you wish to get the non-compressed tutorial by email. |