cylinder

        cylinder [surface-desc]  radius  bx by bz  tx ty tz
Figure 2-7

Create a cylinder of given radius from (bx by bz) to (tx ty tz). Note that cylinders are not solid: in order to do CSG operations using cylinders, you must first close off the end of the cylinder (the disc primitive is ideal for this).

Often the best way to deal with cylinders (and cones) that need to be closed, is to create an object which is a cylinder (centred at 0 0 0) with a disc at each end, then to transform the object to the appropriate position and use it.

Figure 2-8

In this example a closed cylinder object is created, then used to create a tube 10 long with a radius of 4 and a thickness of 0.05. This "tube" is then intersected with a box (that has been rotated at 45 degrees) to produce a curving "shell", like a curving roof.

Figure 2-9

        /*
         cylinder.ray
         cylinder used to create a curving roof shape
         Stephen Peter 22 feb 92
        */
        eyep 8 7 7
        lookp  0 0 3
        screen 300 200
        background .9 .9 .9

        name closed-cyl
            list
                cylinder 1  -0.5 0 0  0.5 0 0
                disc     1  -0.5 0 0   -1 0 0
                disc     1   0.5 0 0    1 0 0
            end

        /* create a cylinder: 10 x 4 (rad) x .05 thick */
        name tube
            difference
                object closed-cyl scale 5.0 4.00 4.00
                object closed-cyl scale 5.1 3.95 3.95
            end

        /* now remove the "lower 3/4 of tube" */
        name quart-tube
            intersect
                object tube
                box -5.1 0 0  5.1 -4.1 4.1  rotate -1 0 0  45
            end

        object  ambient 0 0 .2 diffuse 0 0 .4  quart-tube

Go to next primitive: disc.

Return to Contents.

THE END - Notes on Rayshade - 2 - Rayshade Primitives - Cylinder