Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
Geometric Shapes in POV-Ray
Italiano Italiano
Français français
Deutsch Deutsch

Home
- POV-Ray Tutorial
 
Geometric Shapes
   Overview

Objects in "shapes3.inc"
- Segment_of_CylinderRing
- Segment_of_Torus
- Segment_of_Object
- Egg
- Egg_Shape
- Facetted_Egg
- Facetted_Egg_Shape
- Facetted_Sphere
>Ring_Sphere
- Column_N
- Column_N_AB
- Pyramid_N
- Pyramid_N_AB
- Round_Pyramid_N_out
- Round_Pyramid_N_in
- Round_Cylinder_Tube
- Rounded_Tube_AB
- Rounded_Tube
- Round_N_Tube_Polygon
- Round_Conic_Torus
- Round_Conic_Prism
- Half_Hollowed_Rounded_Cyl1
- Half_Hollowed_Rounded_Cyl2

 
                               
Geometric object definded in my include file "shapes3.inc" (formerly "shapes_lo.inc").
Ring_Sphere
Here some variations of that macro:
Ring_Sphere
Ring_Sphere
general syntax:
object{ Ring_Sphere(
          Rmaj_H, Rmaj_V,
          Rmin_H, Rmin_V,
          Number_of_Rings_horizontal,
          Number_of_Rings_vertical
        ) //------------------------
        texture{ ... ... }
      } // end of object -----------
Rmaj_H, Rmaj_V
= major radius of the horizontal and vertical rings,
Rmin_H, Rmin_V
= minor radius of the horizontal and vertical rings,
Number_of_Rings_horizontal,
Number_of_Rings_vertical.
Example:
#include "shapes3.inc"
object{Ring_Sphere
        (1.00,1.02, 0.025,0.025, 12, 16)
        texture{ pigment{color<1,1,1>}
                 finish{phong 1
                        reflection 0.25}
               } // end of texture
        scale <1,1,1>
        rotate <-20,0,-7>
        translate <0,1.00,0>
      } // end of object ---------------
Ring_Sphere
Ring_Sphere
"Ring_Sphere(1.00, 1.02, 0.005, 0.005, 32, 46)" "Ring_Sphere(1.03, 1.00, 0.015, 0.005, 30, 15)"

Macro in detail
Two while loops of rings, each radius is calculated by cos function:
//----------------------------  macro Ring_Sphere()
#macro Ring_Sphere (Rmaj_H, Rmaj_V,
                    Rmin_H, Rmin_V,
                    Number_of_Rings_horizontal,
                    Number_of_Rings_vertical
                  ) //----------------------------
#if((Rmin_H>0)&(Number_of_Rings_horizontal>0))
#declare RingsH1 =
union{
#local AngleD = 180/(Number_of_Rings_horizontal+1);
#local Nr = -90+AngleD; #local EndNr = 90;

#while (Nr < EndNr)
 #local RingR = Rmaj_H*cos(radians(Nr));
 #local RingH = Rmaj_H*sin(radians(Nr));
 torus{RingR,Rmin_H
       translate<0, RingH,0>}
#local Nr = Nr + AngleD;
#end // --------------- end of loop
}// end union
#end // of "#if((Rmin_H>0)&(Number_of_Rings_horizontal>0))"

#if((Rmin_V > 0) & (Number_of_Rings_vertical > 0))
#local RingsV1 =          // vertical
union{
#local Nr = 0;
#declare EndNr = Number_of_Rings_vertical
#while (Nr < EndNr)
 torus{Rmaj_V-Rmin_V,Rmin_V
       rotate<90,0,0>
       rotate<0, Nr*360/EndNr,0>}
#local Nr = Nr + 1;
#end // --------------- end of loop
}//---------------------------------
#end // of "#if((Rmin_V>0)&(Number_of_Rings_vertical>0))"

union{
  #if (Rmin_H > 0) object{ RingsH1} #end
  #if (Rmin_V > 0) object{ RingsV1} #end
  sphere{<0, Rmaj_H,0>,Rmin_H}
  sphere{<0,-Rmaj_H,0>,Rmin_H}
} // end of union
#end //---------- end of macro Ring_Sphere()

© Friedrich A. Lohmüller, 2013
http://www.f-lohmueller.de