Descriptions and Samples for the POV-Ray raytracer by Friedrich A. Lohmüller
    deutsche Version

Overview overview    

How to Make a Chain

Objects: "sphere", "box", "cylinder".
Methods: "#declare", "union", "difference",
                    "#while", "#if",.

This sample shows how to construct a chain. It is possible to use variable sizes for all messures of the chain links.

The Construction in details:

Step 0: Declare the basic messures of the torus used for the link:
#declare R_min = 0.25;
#declare R_maj = 1.00;
#declare Half_L = 0.25; // half linear part!
#declare Link_Length =  2*(R_maj); 
Step 1: Define a box containing 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 it 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 {ambient 0.15 diffuse 0.85 
                 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 by 90 degrees around the x axis.
This all we can do very economicaly 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 description for a chain with POV-Ray:
".txt" file or ".pov" file

Overview overview    

© Friedrich A. Lohmüller, 2003     email email: (legacy email redacted)