/* A faceted guttered cylinder... Martin 15/09/00 ml_pov@ml1.co.uk */ #include "colors.inc" // A few textures #declare CYAN_METALIC = texture { finish { metallic ambient 0.1 diffuse 0.8 brilliance 6.0 reflection 0.6 phong 1.0 phong_size 80 } pigment { agate color_map { [ 0.0, 0.3 colour blue 0.9 colour blue.8 ] [ 0.3, 1.00 colour blue 0.8 colour blue 0.4 ] } } } #declare RED_PLASTIC = texture { finish { ambient 0.1 diffuse 0.7 phong 1.0 phong_size 70.0 } pigment { color Red } } #declare GREEN_PLASTIC = texture { finish { ambient 0.1 diffuse 0.7 phong 1.0 phong_size 70.0 } pigment { color Green } } #declare BLUE_PLASTIC = texture { finish { ambient 0.1 diffuse 0.7 phong 1.0 phong_size 70.0 } pigment { color Blue } } // A boring background background{ Med_Purple*0.5 } // Wide view camera for added perspective... camera{ location <0,8,-45> angle 60 look_at <0,0,0> } // Lights light_source{ <2, 5, -52> color White media_attenuation on } light_source{ <0,39,-58> color White fade_power 1.75 fade_distance 55 media_attenuation on } // The cylinder with gutter for some data // This example uses random data or a cosine curve // First data point is on the +z axis, going clockwise looking down the +y axis // Not played with #macro yet... #declare cr1 = 13; // cylinder outer radius #declare cr2 = 9; // cylinder inner radius #declare grr = 0.4; // groove radius ratio of cylinder wall thicknes (0.5 = full thickness) #declare cAmplitude = 9; // multiplier for data #declare cOffset = 14; // vertical offset added to the data height #declare nf = 999; // number of facets per revolution #declare nOsc = 3; // number of (cosine) data oscillations per revolution // #declare cRStream = seed(325873); #declare cylinderRevolution = union{ // #declare s2 = cOffset + cAmplitude*rand(cRStream); // random #declare s2 = cOffset + cAmplitude; // Start value #local fCount = 0; // Loop count for the cylinder #local aInc = 360/nf; // Increment angle (degrees) #local crMid = 0.5*(cr1+cr2)*cos(pi/nf); // z-axis distance to centre of segment edge #local bdx = cr1*sin(pi/nf); // Bounding box delta-x for segment #local cbdx = 0.5*(cr1+cr2)*sin(pi/nf); // Bounding box delta-x for segment gutter #local fa = 0.5*aInc; // Segment half angle (degrees) #local gr = grr*(cr1*cos(pi/nf)-cr2); // Gutter cylinder radius #while (fCount,<9*(gr+dy+bdx),0,crMid> gr inverse texture{BLUE_PLASTIC} // Show the gutter in blue rotate degrees(slope2)*z translate (0.5*(s1+s2)+gr/cos(slope2)-gr)*y } // bounded_by { box{<-bdx,by-dy-gr/cos(slope2),cr2*cos(pi/nf)>,} } // Unexpected results! } // intersection 1 cylinder{0,by*y cr1 texture{RED_PLASTIC} // Show the outside cylinder in red } cylinder{-0.001*y,(0.001+by)*y cr2 inverse texture{RED_PLASTIC} // Show the inside cylinder in red } plane{x, 0 rotate fa*y // Segment edge } plane{-x, 0 rotate -fa*y // Segment edge } // And the bounding box to drastically speed things up bounded_by { box{<-bdx,0,cr2*cos(pi/nf)>,} } } // intersection rotate fCount*aInc*y // clockwise from z looking down along y } #end } // Place the cylinder object{ cylinderRevolution translate -0.5*(cOffset+cAmplitude)*y texture{GREEN_PLASTIC} }