// Spiral Test File december 2010 // By J.J.Frank #declare Major_Radius = 2; #declare Minor_X_Radius = 0.4; #declare Minor_Y_Radius = 0.8; #declare Speed = -2; #declare Turns = 5.5; //CONTROL SECTION #declare Major_Radius = ((Major_Radius != 0) ? abs(Major_Radius) : 1); #declare Minor_X_Radius = ((Minor_X_Radius != 0) ? abs(Minor_X_Radius) : 0.1); #declare Minor_Y_Radius = ((Minor_Y_Radius != 0) ? abs(Minor_Y_Radius) : 0.01); #declare Speed = ((Speed != 0) ? Speed : 1); #declare Turns = ((Turns != 0) ? abs(Turns) : 1); //INTERNAL PARAMETERS #if (Speed>0) #declare Up = true; // Up = anti-clockwise #else #declare Up = false; #declare Speed = abs(Speed); #end #declare Ellipticity = Minor_X_Radius / Minor_Y_Radius; // POLY 8 #declare Slope = Speed / 4; // POLY 8 #declare A2 = Minor_X_Radius * Minor_X_Radius; // POLY 8 #declare P2 = Slope * Slope; // POLY 8 #declare R2 = Major_Radius * Major_Radius; // POLY 8 #declare T2 = Ellipticity * Ellipticity; // POLY 8 #declare Phi = degrees(atan2(Slope,1)); // Clipping #declare Thick = ((Minor_X_Radius > Minor_Y_Radius) ? // Clipping Minor_X_Radius : Minor_Y_Radius); #declare Long = Major_Radius * sqrt(1 + P2); // Clipping #declare High = Slope * Major_Radius; // Building #declare IntTurns = int(Turns); // Building #declare Fraction = Turns - IntTurns; // Building camera { location < 2, 5.5, -5 > look_at < 0.1, 5.5, 0 > } /* *************************** Poly 8 ********************************** */ #declare Spiral_Shape = object { polynom { 8 // 165 factors /* x^8 */ xyz(8,0,0): 1 /* x^6.y^2 */ xyz(6,2,0): 2*T2 /* x^6.z^2 */ xyz(6,0,2): 4 /* x^6 */ xyz(6,0,0): -2*((1-P2*T2)*R2+A2) /* x^5.y */ xyz(5,1,0): -8*R2*Slope*T2 /* x^4.y^4 */ xyz(4,4,0): T2*T2 /* x^4.y^2.z^2 */ xyz(4,2,2): 6*T2 /* x^4.y^2 */ xyz(4,2,0): 2*T2*((1-P2*T2)*R2-A2) /* x^4.z^4 */ xyz(4,0,4): 6 /* x^4.z^2 */ xyz(4,0,2): -2*((3-2*P2*T2)*R2+3*A2) /* x^4 */ xyz(4,0,0): ((1+P2*T2)*R2-A2)*((1+P2*T2)*R2-A2) /* x^3.y.z^2 */ xyz(3,1,2): -16*R2*Slope*T2 /* x^2.y^4.z^2 */ xyz(2,4,2): 2*T2*T2 /* x^2.y^2.z^4 */ xyz(2,2,4): 6*T2 /* x^2.y^2.z^2 */ xyz(2,2,2): 2*T2*((2-P2*T2)*R2-2*A2) /* x^2.z^6 */ xyz(2,0,6): 4 /* x^2.z^4 */ xyz(2,0,4): -2*((3-P2*T2)*R2+3*A2) /* x^2.z^2 */ xyz(2,0,2): 2*(R2-A2)*((1+P2*T2)*R2-A2) /* x.y.z^4 */ xyz(1,1,4): -8*R2*Slope*T2 /* y^4.z^4 */ xyz(0,4,4): T2*T2 /* y^2.z^6 */ xyz(0,2,6): 2*T2 /* y^2.z^4 */ xyz(0,2,4): 2*T2*(R2-A2) /* z^8 */ xyz(0,0,8): 1 /* z^6 */ xyz(0,0,6): -2*(R2+A2) /* z^4 */ xyz(0,0,4): (R2-A2)*(R2-A2) /* C */ xyz(0,0,0): 0.000000001 sturm } // end poly } // end object // With C = 0 you can get a system break (in 1997 with version 3.1). //HALF TURN BUILDING BLOCK #if ((IntTurns >=1) | (Fraction >= 0.5)) // Only when it is needed. #declare HalfSpiral = object { Spiral_Shape #if ((Long - Thick - 0.000001) > 0 ) // Then the inner cylinder is clipped_by { // possible. plane { ((Up = true) ? -z : z), 0 } } // Front or back half. #else //#if ((Long - Thick - 0.000001) > 0 ) clipped_by { plane { ((Up = true) ? -z : z), 0 } } #end //#else ((Long - Thick - 0.000001) > 0 ) bounded_by { clipped_by } // Saves lots of render time. } // end object HalfSpiral #end //#If ((IntTurns >=1) | (Fraction >= 0.5)) //COMPLETE TURN BUILDING BLOCK #if (IntTurns >=1) // Only when it is needed. #declare OneSpiral = union { object { HalfSpiral translate High * y } object { HalfSpiral rotate 180 * y translate 3 * High * y } } #end //PARTIAL TURN BUILDING BLOCK #if ((Fraction > 0) & (Fraction != 0.5)) // Only when it is needed. #declare PartSpiral = object { Spiral_Shape #if ((Long - Thick - 0.000001) > 0 ) clipped_by { plane { (Up = true ? -z : z), 0 } plane { (Up = true ? z : -z) , 0 rotate ((Fraction > 0.5) ? (Fraction - 0.5) : Fraction) * (Up = true ? 360 : -360) * -y } } #else //#if ((Long - Thick - 0.000001) > 0 ) clipped_by { plane { (Up = true ? -z : z), 0 } plane { (Up = true ? z : -z) , 0 rotate ((Fraction > 0.5) ? (Fraction - 0.5) : Fraction) * (Up = true ? 360 : -360) * -y } } #end //#else ((Long - Thick - 0.000001) > 0 ) bounded_by { clipped_by } } // end object PartSpiral #end //#if ((Fraction > 0) & (Fraction != 0.5)) //BUILDING OF THE SPIRAL #declare Count = 0; #if (IntTurns >= 1) // >= 1 complete turn. #declare Spiral = OneSpiral; // First complete turn. #declare Count = Count + 4; #while (Count < (IntTurns * 4) ) // More complete turns. #declare Spiral = union { object { Spiral } object { OneSpiral translate Count * High * y } } #declare Count = Count + 4; #end //#while (Count < (IntTurns * 4) ) #if (Fraction>0) // Fractional turn. #declare Spiral = union { object { Spiral } // What we already had build. #if (Fraction>=0.5) object { HalfSpiral translate (Count + 1) * High * y } // « turn. #end //#if (Fraction>=0.5) #if (Fraction != 0.5) // Fractional turn. object { PartSpiral translate (Count + (Fraction > 0.5 ? 3 : 1) ) * High * y rotate (Fraction > 0.5 ? 180 : 0) * y } #end //#if (Fraction != 0.5) } // end union #end //#if (Fraction>0) #else //#if (IntTurns >= 1) // < 1 complete turn. #if (Fraction>=0.5) // >= 0.5 turn. #declare Spiral = union { object { HalfSpiral translate High * y } // « turn. #if (Fraction > 0.5) // Fractional turn. object { PartSpiral translate 3 * High * y rotate 180 * y } #end //#if (Fraction > 0.5) } //end union #else //#if (Fraction>=0.5) // < 0.5 turn. #declare Spiral = object { PartSpiral // Fractional turn. translate High * y } #end //#else (Fraction>=0.5) #end //#else (IntTurns >= 1) // end of spiral.inc #declare Spiral1 = Spiral #include "colors.inc" object { Spiral1 pigment { checker scale 0.1 } } object { plane { y, 0 } pigment { color Yellow } } light_source { < 100, 100, -100 > color White } // rechts,boven,achter light_source { < -100, 100, -100 > color White } // links,boven,achter light_source { < -100, 100, 100 > color White } // links,boven,voor light_source { < 100, 100, 100 > color White } // rechts,boven,voor