sphere

        sphere [surface-desc]  radius  cx cy cz
Figure 2-16

Create a sphere centred at (cx cy cz) with the given radius.

The example below creates a bowl by using a box to "cut" a sphere in half then using a sphere (that is slightly smaller than the first sphere) to "cut" away the inside of the bowl. The outside of the sphere uses the surface "red", the inside uses the surface "green". The top of the bowl, in the example, is flat; to have a rounded top, add a torus onto the top of the bowl.

Figure 2-17

        /*
         bowl.ray
         a bowl (using spheres)
         Stephen Peter 22 feb 92
        */
        eyep  .9 5 3
        lookp  1 1 .5
        screen 300 300
        light 1 point -3 3 6

        background .9 .9 .9

        surface red
            ambient  0.3 0.1 0.1
            diffuse  0.3 0.1 0.1
            specular 0.3 0.1 0.1

        surface green
            ambient  0.1 0.3 0.1
            diffuse  0.1 0.3 0.1
            specular 0.1 0.3 0.1

        /* bowl */
        difference
            difference
                sphere red 1  1 1 1
                box red 0 0 1   3 3 3
            end
            sphere green .95 1 1 1
        end

Go to next primitive:
torus.

Return to Contents.

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