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

macro "Segment_of_CylinderRing (...)" overview my macro objects macro "Segment_of_Object (...)"

This shape is definded as "macro" in my include file "shapes_lo.inc":

Torus_Segment

Segment_of_Torus


    Segment of a Torus
 
general syntax:
object{ Segment_of_Torus (R_major, R_minor, Segment_Angle)
        texture{ ... ... }
      } // end of object ------------
With:
R_major = the major radius of the torus,
R_minor = the minor radius of the torus,
Segment_Angle = the angle of the segment of the torus.

For reasons of compatibility the old macro "Torus_Segment"
still exists - there the angle was orientated in a righthanded sense!
Samples:
#include "shapes_lo.inc"
object{ Segment_of_Torus( 1.00, 0.25, -145)
        texture { pigment{color rgb<1,0.7,0>}
                  finish {ambient 0.15 diffuse 0.85 phong 1}
                } // end of texture
        rotate<-90,0,0> translate<0,1,0>
      } // end of Segment_of_Torus(...) -----------------------


object{ Segment_of_Torus( 0.60, 0.25, -275)
        texture { pigment{color rgb<1,0.4,0>}
                  finish {ambient 0.15 diffuse 0.85 phong 1}
                } // end of texture
        rotate<0,30,0> translate<0.5,0.3,-0.5>
      } // end of Segment_of_Torus(...) -----------------------

object{ Segment_of_Torus( 0.60, 0.50, -60)
        texture { pigment{color rgb<1,0.2,0>}
                  finish {ambient 0.15 diffuse 0.85 phong 1}
                } // end of texture
        rotate<-90,0,-190> translate<0,1,0>
      } // end of Segment_of_Torus(...) ----------------------- 


Macro in detail

For this we have to consider two cases:
1. abs(Segment_Angle) <= 180 degrees (just an intersection of the torus and the two boxes) and
2. abs(Segment_Angle) > 180 degrees (an intersection of the torus and the union of the two boxes):

//--------------------------------------------------------Segment_of_Torus macro
#macro Segment_of_Torus ( R_major, R_minor, Segment_Angle)
//---------------------------------------------------------------------------
#local D =  0.00001;
 #if (Segment_Angle < 0)
      #local Negativ_Flag = 1;
      #local Segment_Angle = -Segment_Angle;
 #else
      #local Negativ_Flag = 0;
 #end
 #if (Segment_Angle > 360) #local Segment_Angle = mod(Segment_Angle,360); #end

intersection{
 torus { R_major, R_minor }

#if (Segment_Angle > 180)
 union{
#end // use union!

 box   { <-1,-1,0>,<1,1,1>
         scale < R_major+R_minor+D, R_minor+D, R_major+R_minor+D>
       }// end of box
 box   { <-1,-1,-1>,<1,1,0>
         scale < R_major+R_minor+D, R_minor+D, R_major+R_minor+D>
         rotate < 0,-Segment_Angle,0 >
       }// end of box

#if (Segment_Angle > 180)
 }
#end // end of union, if union is used!

 #if (Negativ_Flag = 0)  rotate<0, Segment_Angle,0>   #end

 } // end of intersection
#end  // ----------------------------- end of macro Segment_of_Torus

The following images show how this macro works
(the boxes are visualizised in texture glass):

 
Segment_of_Torus Segment_of_Torus
abs(Segment_Angle) <= 180 degrees
R_major = 1.00, R_minor = 0.25, Angle = -145
abs(Segment_Angle) > 180 degrees
R_major = 1.00, R_minor = 0.25, Angle = -215






macro "Segment_of_CylinderRing (...)" overview my macro objects macro "Segment_of_Object (...)"

© Friedrich A. Lohmüller, 2004
email email: (legacy email redacted)
homepage:www.f-lohmueller.de