Example 2

Let us take a look at the way of generating the following:

Click here to download a complete scene file.

The overall structure is the following.

Let us start with the "spokes". The "generator" is a box as follows, where Thickness is 1.

#declare  OneSpoke =
               box { < -0.5, -Thickness, -5 >, < 0.5, Thickness, 5 > }
To produce all twelve of them, the above box is rotated 30, 60, 90, 120 and 150 degrees.
#declare  Spokes =
               union {
                    #declare   Angle = 0
                    #while (Angle <= 150)
                         object { OneSpoke  rotate Angle*y }
                         #declare  Angle = Angle + 30
                    #end
               }
Therefore, we have six boxes in different positions and due to symmetry they generate 12 "spokes" as shown in figure (a) below.

The body of the gear is simply a cylinder with thickness a little larger than that of the boxes. The boxes have thickness 1 and therefore the body has thickness 1.1. A union is required to put the above six boxes and this body cylinder together as shown below. The result is in above figure (b). In the following, Thickness and OuterRadius are 1 and 4, respectively.

#declare  Body_Primitive =
               union {
                    object { Spokes }
                    cylinder { -(Thickness + 0.1)*y,
                                (Thickness + 0.1)*y, OuterRadius }
               }
The center part of the gear should be a little thinner than the outer part. To do so, two cylinders are used to remove some part of the body surface. These two cylinders have radius InnerRadius 3.5. Then, they are translated in the y-direction to Offset = 1.6 and subtracted from the gear body. The following is the POV-Ray definition and its result is shown in figure (c) above.
#declare  Remove =
               cylinder { -Thickness*y, Thickness*y, InnerRadius }

#declare  Body_Without_Holes =
               difference {
                    object { Body_Primitive }
                    object { Remove  translate   Offset*y }
                    object { Remove  translate  -Offset*y }
               }
Next, let us punch eight holes. These holes are generated from the following. It is a cylinder with center at HoleCenter = ( 2.5, 0, 0 ) and radius HoleRadius = 0.5. The height of this cylinder is the thickness of the body.
#declare  Hole_Puncher =
               cylinder {
                    HoleCenter - Thickness*y,
                    HoleCenter + Thickness*y,
                    HoleRadius
               }
These holes are punched with a #while loop as follows. Its result is shown in figure (d) above.
#declare  Body_With_Holes =
               difference {
                    object { Body_Without_Holes }
                    #declare  Angle = 0
                    #while  (Angle < 360)
                         object { Hole_Puncher  rotate  Angle*y }
                         #declare  Angle = Angle + 45
                    #end
               }
Then, we should add a shaft base. It is a cylinder with radius AxisOuterRadius = 1.6:
#declare  Body_With_Axis_Base =
               union {
                    object { Body_With_Holes }
                    cylinder { -Thickness*y, Thickness*y, AxisOuterRadius }
               }
The result is shown in figure (e) above. Finally, punching a hole for the shaft completes our work. To punch this hole, a cylinder with radius AxisInnerRadius = 1 is used and the final result is shown in the beginning of this page.
#declare  Body =
               difference {
                    object { Body_With_Axis_Base }
                    cylinder { -2*Thickness*y, 2*Thickness*y, AxisInnerRadius }
               }