Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
    POV-Ray Examples - How To Make Objects for POV-Ray
Italiano Italiano
Français français
Deutsch Deutsch

Home
- POV-Ray Tutorial
  - POV-Ray Examples
   Index of Content
  - Geometry
  - Architecture
  - Engineering
    - Ladder
    - Pylons
    - Railing
    - Bridge
    - Tubes
    - Tube Fork
    - Tube Stopcock
    - Chain
    - Coil of Wire
    - Torpedo
    - Cruise Missile
    - Rocket
    - Wheel
    - Truck
    - Propeller
    - Airplanes
    - Canoe
    - Guitar Body
    - 7-Segment Display
    - Ribbon Cable
    - Cable Harness
                                       
 
Chain

Links of a Chain
and a Chain

Objects: sphere, box, cylinder.
Methods: #declare, union, difference, #while, #if.
This example shows how to construct a chain. It is possible to use variable sizes for all dimensions of the chain links.

The Construction in details:
 
Step 0: Declare the basic sizes of the torus used for the link:
#declare R_min = 0.25;
#declare R_maj = 1.00;
#declare Half_L = 0.25;
 // = half straight part!
#declare Link_Length =  2*(R_maj);       
Step 1: Define a box which contains the right half of the torus and subtract this box form the torus:
difference{
 torus { R_maj, R_min
         rotate <90,0,0>
       } // end of torus  -------------- 
 box{<           0,-R_maj-R_min,-R_min>,
     < R_maj+R_min, R_maj+R_min, R_min>
    }// end of box
 }// end of difference

chain
chain
chain

Step 2: Move the half torus to the left by the half length of the linear part of the chain link. Then add one (only one!) of this linear parts of the link.
After all declare this as a new object "Left_Half" and mirror this element at <0,0,0>:

#declare Left_Half =
union{
difference{
 torus { R_maj, R_min
         rotate <90,0,0>
       } // end of torus  ------------- 
 box{<          0,-R_maj-R_min,-R_min>,
     <R_maj+R_min, R_maj+R_min, R_min>
    }// end of box

 translate <-Half_L,0,0>
 }// end of difference

 cylinder {
    <-Half_L,0,0>,<Half_L,0,0>, R_min
    translate <0,R_maj,0>
  } // end of cylinder
}// end of union
//------------------------------------- 
#declare Chain_Link =
union{
object{ Left_Half }
object{ Left_Half scale <-1,-1,1>}

texture{
   pigment{color rgb<1,1,1>*0.2}
   normal {bumps 0.125 scale 0.015}
   finish {phong 0.5 reflection 0.2}
       } // end of texture
} // end of Chain_Element 
chain
chain

Step 3: For building a chain we need to move the links by the declared "Link_Length" and turn each second link by 90 degrees around the x axis.
This all we can do very economically by a while loop:

chain
union{
 #declare Nr = 0;    // start
 #declare EndNr = 6; // end
 #while (Nr< EndNr)
   object{ Chain_Link
           #if ( int(Nr/2) ! = Nr/2 )
                rotate <90,0,0>
           #end
           translate <Nr*Link_Length,0,0> 
         }
 #declare Nr = Nr + 1;  // next Nr
 #end // ----------------- end of loop
} // end of union
 
chain

Scene file for a chain with POV-Ray:
"chain.txt" or "chain.pov"
 
top

© Friedrich A. Lohmüller, 2009
www.f-lohmueller.de