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
                                       
 
Ladder

Ladder

with "macro" and while loop
Objects: cylinder.
Methods: #declare, #local, union, #macro, #while.

An include file to use this object as a read-made object
you can find at my POV-Ray Objects page.

The following "macro" produces a ladder. Here we have to define the radius of the lateral cylinders, the radius of the steps, the half width of the steps as well as the height of the ladder and distance of the steps. The number of steps is calculated by the height and the distance in this "macro". The steps are placed with a while loop.

Definition of the dimensions and texture:

//------------------------------ Dimensions
#declare LR1 = 0.025; // radius latteral
#declare LR2 = 0.010; // radius of steps
#declare LW = 0.23-LR1;// half width
#declare LH = 3.20;   // height
#declare Step_Distance = 0.25;
//--------------------------------- texture
#declare Texture_L =
 texture{pigment{color White}
         finish {diffuse 0.9 phong 1}} 

The "macro" itself:

//---------------------------------- Ladder
#macro Ladder (R1_L,R2_L,W_L,H_L,Step_Dist)
#local Step_Totals = int(H_L / Step_Dist);
#local Step =
      cylinder{<-W_L,0,0>,<W_L,0,0>,R2_L}

#local Nr  = 0;             // start
#local EndNr = Step_Totals; // end
union{
#while (Nr < EndNr)
 object{Step
        translate<0,(Nr+0.5)*Step_Dist,0>}
 #declare Nr = Nr + 1;  // next Nr
#end // --------------- end of loop
// cylinders latteral:
cylinder{<0,0,0>,<0,H_L,0>,R1_L
         translate< W_L,0,0>}
cylinder{<0,0,0>,<0,H_L,0>,R1_L
         translate<-W_L,0,0>}
 }// end of union
#end // end of macro  "Ladder (...)
//----------------------------------------- 

Calling the "macro" object:

>object{ Ladder(LR1,LR2,LW,LH,Step_Distance)
             texture{Texture_L}
      } // end of object
//------------------------------------- end 
Ladder
Scene description
for POV-Ray:
"ladder.txt"
or "ladder.pov"
 
Ready-made POV-Ray objects as
include files and example files you'll find
at the POV-Ray Objects Page
top

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