POV-Ray : Newsgroups : povray.binaries.scene-files : Harmonagraph Server Time
28 Mar 2024 06:13:03 EDT (-0400)
  Harmonagraph (Message 1 to 1 of 1)  
From: AQ
Subject: Harmonagraph
Date: 23 Sep 2016 12:16:25
Message: <b3laubhopa6jq34343aivdrfht9uoec5v9@4ax.com>
This is the scene file for the Harmonagraph

AQ
// Persistence of Vision Ray Tracer Scene Description File
// File: Harmonograph xx.pov
// Vers: 3.7 

// Desc: Simulation of a 2 pendulum harmonograph
// Date: September 2016
// Auth: John Cranmer

#version 3.7;

global_settings { 
  assumed_gamma 1.0
} 

#declare Single_Col     = rgb <1.0, 0.5, 0.2>;   // single colour pattern 
#declare Rainbow        = true;                  // rainbow coloured trace. Single
colours do not work well
#declare Rand_Col       = false;                 // randomised colour map
#declare R              = seed (99);             // seed for random number generation

#declare Radius         = 0.02;                  // radius of the cylinders used to
draw the pattern (0.01 to 0.05)
#declare Number         = 250000;                // Number of points to draw  (100,000
to 250,000 work)
#declare r              = 1.5/Number;      
#declare S              = 12;                    // scale factor for drawing 
#declare Front_to_Back  = true;                  // draw front to back or back to
front - as cylinders are offset in z makes a considerable difference
#declare xScale         = 1.3;

#declare f1             = 1.25;                   // frequency
#declare f2             = 7.5;
#declare f3             = 8;
#declare f4             = 5;

#declare a1             = 180;                    // initial offset
#declare a2             = 90;
#declare a3             = 0;
#declare a4             = 45;

#declare e              = 2.71828183;

// ******************************************************************************** 
camera {
  location < 0, 0,-80>
  look_at  < 0, 0,  0> 
  right x * image_width / image_height
  angle 50
}

light_source { 
  -z * 200
  color 1
  shadowless
}

background { rgb 0.5 }                                                

// ********************************************************************************
// Load colour values into the array
#declare Col = array[7][4]
#for (j,0,6,1)
  #for (k,1,3,1)
    #declare Col[j][k] = int(2*rand(R));
  #end
#end  


// Calculate initial start point
#declare n = 0;    
#declare xnew = S * pow(e,-r*n) * (sin(radians(f1 * 2*n + a1)) + sin(radians(f2 * n +
a2)));     // NB THE CHANGE IN THIS LINE
#declare ynew = S * pow(e,-r*n) * (sin(radians(f3 * n + a3)) + sin(radians(f4 * n +
a4)));

#declare n = 1;
#if (Front_to_Back = true)
  #declare FB =  1; 
#else
  #declare FB = -1;
#end
 
#declare Harmonograph = union {
  #while  ( n < Number )
    #declare xold = xnew;
    #declare yold = ynew;
    #declare xnew = S * pow(e,-r*n) * (sin(radians(f1 * 2*n + a1)) + sin(radians((f2 *
n + a2))));       // NB THE CHANGE IN THIS LINE as well 
    #declare ynew = S * pow(e,-r*n) * (sin(radians(f3 * n + a3)) + sin(radians((f4 * n
+ a4))));
    cylinder { <xold, yold, FB*n*0.02/Number> <xnew, ynew, FB*n*0.02/Number> Radius 
      texture {
        #if ( Rainbow = true)
          #if (Rand_Col = true)
            pigment {
              function { n / Number }                  // change colour for each
cylinder
              colour_map {
                [0.0/6  rgb < Col[0][1], Col[0][2], Col[0][3] >]        
                [1.5/6  rgb < Col[1][1], Col[1][2], Col[1][3] >] 
                [2.0/6  rgb < Col[2][1], Col[2][2], Col[2][3] >] 
                [3.0/6  rgb < Col[3][1], Col[3][2], Col[3][3] >] 
                [4.0/6  rgb < Col[4][1], Col[4][2], Col[4][3] >] 
                [5.0/6  rgb < Col[5][1], Col[5][2], Col[5][3] >] 
                [6.0/6  rgb < Col[6][1], Col[6][2], Col[6][3] >]
              }
            }
          #else
            pigment {
              function { n / Number }                 
              colour_map {
                [0.0/6  rgb < 0, 0, 1 >]        
                [1.5/6  rgb < 1, 0, 1 >] 
                [2.0/6  rgb < 1, 0, 0 >] 
                [3.0/6  rgb < 1, 1, 0 >] 
                [4.0/6  rgb < 0, 1, 0 >] 
                [5.0/6  rgb < 0, 1, 1 >] 
                [6.0/6  rgb < 0, 0, 1 >]
              }
            }
          #end  
        #else
          pigment { Single_Col }
        #end
      } 
    }
    #declare n = n + 1;
  #end 
}

// Draw the pattern
object { Harmonograph
  scale x * xScale 
  translate x * 0 
  rotate z * 0  
}


Post a reply to this message

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