POV-Ray : Newsgroups : povray.text.scene-files : "More Faceted Torii Examples" Source Code Server Time
1 Nov 2024 11:15:00 EDT (-0400)
  "More Faceted Torii Examples" Source Code (Message 1 to 1 of 1)  
From: Tor Olav Kristensen
Subject: "More Faceted Torii Examples" Source Code
Date: 19 Jun 2000 16:48:44
Message: <394E86A7.E080DD99@online.no>
Below is the source code for an image I posted 19. June to the
povray.binaries.images news group.

The source code below contains a modified version of one of
Samuel Benge's macros.

See his postings to povray.binaries.images 14. June;
"Faceted Torus Macro Example" and to
povray.binaries.scene-files 15. June; "Faceted Torus Macro"


Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.1;
#include "colors.inc"

global_settings { ambient_light 0.8 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro mTri_Torus(MaxR, MinR, Num, CylR, Type)

//  I'm not sure what use there could be for the next line
//  #local MinR = MinR - (MaxR = MinR ? 0 : 0.0001);

  #local vMaxR = MaxR*<1, 0, 1>;
  #local dAngle = 2*pi/Num;

  #local R1 = dAngle/2;
  #local NsinR1 = sin(R1);
  #local NcosR1 = cos(R1);
  #while(R1 < 2*pi)
    #local TsinR1 = NsinR1;
    #local TcosR1 = NcosR1;
    #local R1 = R1 + dAngle;
    #local NsinR1 = sin(R1);
    #local NcosR1 = cos(R1);
    #local R2 = dAngle/2;
    #local NsinR2 = sin(R2);
    #local NcosR2 = cos(R2);
    #while(R2 < 2*pi)
      #local TsinR2 = NsinR2;
      #local TcosR2 = NcosR2;
      #local R2 = R2 + dAngle;
      #local NsinR2 = sin(R2);
      #local NcosR2 = cos(R2);
      #local Pos0 = <TsinR2, TcosR1, TcosR2>*
                    (vMaxR + MinR*<TsinR1, 1, TsinR1>);
      #local Pos1 = <NsinR2, NcosR1, NcosR2>*
                    (vMaxR + MinR*<NsinR1, 1, NsinR1>);
      #local Pos2 = <NsinR2, TcosR1, NcosR2>*
                    (vMaxR + MinR*<TsinR1, 1, TsinR1>);
      #local Pos3 = <TsinR2, NcosR1, TcosR2>*
                    (vMaxR + MinR*<NsinR1, 1, NsinR1>);
      #switch (Type)
        #case (0)
          sphere { Pos0, CylR }
          #break
        #case (1)
          cylinder { Pos0, Pos3, CylR }
          #break
        #case (2)
          cylinder { Pos0, Pos2, CylR }
          #break
        #case (3)
          cylinder { Pos2, Pos3, CylR }
          #break
        #case (4)
          cylinder { Pos0, Pos1, CylR }
          #break
        #case (5)
          triangle { Pos0, Pos2, Pos3 }
          #break
        #case (6)
          triangle { Pos1, Pos2, Pos3 }
          #break
        #case (7)
          triangle { Pos0, Pos1, Pos3 }
          #break
        #case (8)
          triangle { Pos0, Pos1, Pos2 }
          #break
        #else
          #debug "\nMacro mTri_Torus: Wrong type given.\n"
      #end // switch
    #end // while
  #end // while

#end // macro mTri_Torus

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Dist = 8;
#declare RMaj = 2;
#declare RMin = 1;

#declare Nr = 15;

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 5) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 6) pigment { color Grey    }
}
  translate -Dist*(x + z)
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 0) pigment { color Cyan    }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 4) pigment { color Cyan    }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 7) pigment { color Magenta }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 8) pigment { color Red     }
}
  translate -Dist*z
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 7) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 8) pigment { color White   }
}
  translate  Dist*(x - z)
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.10, 0) pigment { color Green   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 3) pigment { color Cyan    }
}
  translate -Dist*x
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.10, 0) pigment { color Magenta }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 1) pigment { color Grey    }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 2) pigment { color Grey    }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 5) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 6) pigment { color White   }
}
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.10, 0) pigment { color Green   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 1) pigment { color Orange  }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 2) pigment { color Red     }
}
  translate  Dist*x
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 1) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 3) pigment { color White   }
}
  translate  Dist*(-x + z)
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.10, 0) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 1) pigment { color Red     }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 2) pigment { color Red     }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 3) pigment { color Yellow  }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 4) pigment { color Yellow  }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 7) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.00, 8) pigment { color White   }
}
  translate  Dist*z
}

union {
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 0) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 3) pigment { color White   }
}
  union { mTri_Torus(RMaj, RMin, Nr, 0.05, 4) pigment { color White   }
}
  translate  Dist*(x + z)
}

sky_sphere { pigment { color Blue/2 } }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

light_source { 40*<1, 2, 1>, color White }

camera {
  location 18*<0, 1, 1>
  look_at  -3*<0, 1, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.