// Spiral Test File december 2010 // By J.J.Frank #declare Major_Radius = 1; #declare Minor_X_Radius = 0.7; #declare Minor_Y_Radius = 0.1; #declare Speed = -1; #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 /**/ // *******angle 45************************************* camera { location < 2, 5.5, -5*1 > look_at < 0.1, 5.5-2, 0 > angle 45} /* // *******angle 15*************************************** camera { location < 2, 5.5, -5*3.75> look_at < 0.1, 5.5-2, 0 > angle 15} */ /* // *******angle 05************************************** camera { location < 2, 5.5, -5*14 > look_at < 0.1, 5.5-2, 0 > angle 5} // ****************************************************** */ // *************************** Poly 8 ********************************** #declare Spiral_Shape = object { poly { 8 // 165 factors /* x^8 */ < 1 /* x^7.y */ , 0 /* x^7.z */ , 0 /* x^7 */ , 0 /* x^6.y^2 */ , 2*T2 /* x^6.y.z */ , 0 /* x^6.y */ , 0 /* x^6.z^2 */ , 4 /* x^6.z */ , 0 /* x^6 */ , -2*((1-P2*T2)*R2+A2) /* x^5.y^3 */ , 0 /* x^5.y^2.z */ , 0 /* x^5.y^2 */ , 0 /* x^5.y.z^2 */ , 0 /* x^5.y.z */ , 0 /* x^5.y */ , -8*R2*Slope*T2 /* x^5.z^3 */ , 0 /* x^5.z^2 */ , 0 /* x^5.z */ , 0 /* x^5 */ , 0 /* x^4.y^4 */ , T2*T2 /* x^4.y^3.z */ , 0 /* x^4.y^3 */ , 0 /* x^4.y^2.z^2 */ , 6*T2 /* x^4.y^2.z */ , 0 /* x^4.y^2 */ , 2*T2*((1-P2*T2)*R2-A2) /* x^4.y.z^3 */ , 0 /* x^4.y.z^2 */ , 0 /* x^4.y.z */ , 0 /* x^4.y */ , 0 /* x^4.z^4 */ , 6 /* x^4.z^3 */ , 0 /* x^4.z^2 */ , -2*((3-2*P2*T2)*R2+3*A2) /* x^4.z */ , 0 /* x^4 */ , ((1+P2*T2)*R2-A2)*((1+P2*T2)*R2-A2) /* x^3.y^5 */ , 0 /* x^3.y^4.z */ , 0 /* x^3.y^4 */ , 0 /* x^3.y^3.z^2 */ , 0 /* x^3.y^3.z */ , 0 /* x^3.y^3 */ , 0 /* x^3.y^2.z^3 */ , 0 /* x^3.y^2.z^2 */ , 0 /* x^3.y^2.z */ , 0 /* x^3.y^2 */ , 0 /* x^3.y.z^4 */ , 0 /* x^3.y.z^3 */ , 0 /* x^3.y.z^2 */ , -16*R2*Slope*T2 /* x^3.y.z */ , 0 /* x^3.y */ , 0 /* x^3.z^5 */ , 0 /* x^3.z^4 */ , 0 /* x^3.z^3 */ , 0 /* x^3.z^2 */ , 0 /* x^3.z */ , 0 /* x^3 */ , 0 /* x^2.y^6 */ , 0 /* x^2.y^5.z */ , 0 /* x^2.y^5 */ , 0 /* x^2.y^4.z^2 */ , 2*T2*T2 /* x^2.y^4.z */ , 0 /* x^2.y^4 */ , 0 /* x^2.y^3.z^3 */ , 0 /* x^2.y^3.z^2 */ , 0 /* x^2.y^3.z */ , 0 /* x^2.y^3 */ , 0 /* x^2.y^2.z^4 */ , 6*T2 /* x^2.y^2.z^3 */ , 0 /* x^2.y^2.z^2 */ , 2*T2*((2-P2*T2)*R2-2*A2) /* x^2.y^2.z */ , 0 /* x^2.y^2 */ , 0 /* x^2.y.z^5 */ , 0 /* x^2.y.z^4 */ , 0 /* x^2.y.z^3 */ , 0 /* x^2.y.z^2 */ , 0 /* x^2.y.z */ , 0 /* x^2.y */ , 0 /* x^2.z^6 */ , 4 /* x^2.z^5 */ , 0 /* x^2.z^4 */ , -2*((3-P2*T2)*R2+3*A2) /* x^2.z^3 */ , 0 /* x^2.z^2 */ , 2*(R2-A2)*((1+P2*T2)*R2-A2) /* x^2.z */ , 0 /* x^2 */ , 0 /* x.y^7 */ , 0 /* x.y^6.z */ , 0 /* x.y^6 */ , 0 /* x.y^5.z^2 */ , 0 /* x.y^5.z */ , 0 /* x.y^5 */ , 0 /* x.y^4.z^3 */ , 0 /* x.y^4.z^2 */ , 0 /* x.y^4.z */ , 0 /* x.y^4 */ , 0 /* x.y^3.z^4 */ , 0 /* x.y^3.z^3 */ , 0 /* x.y^3.z^2 */ , 0 /* x.y^3.z */ , 0 /* x.y^3 */ , 0 /* x.y^2.z^5 */ , 0 /* x.y^2.z^4 */ , 0 /* x.y^2.z^3 */ , 0 /* x.y^2.z^2 */ , 0 /* x.y^2.z */ , 0 /* x.y^2 */ , 0 /* x.y.z^6 */ , 0 /* x.y.z^5 */ , 0 /* x.y.z^4 */ , -8*R2*Slope*T2 /* x.y.z^3 */ , 0 /* x.y.z^2 */ , 0 /* x.y.z */ , 0 /* x.y */ , 0 /* x.z^7 */ , 0 /* x.z^6 */ , 0 /* x.z^5 */ , 0 /* x.z^4 */ , 0 /* x.z^3 */ , 0 /* x.z^2 */ , 0 /* x.z */ , 0 /* x */ , 0 /* y^8 */ , 0 /* y^7.z */ , 0 /* y^7 */ , 0 /* y^6.z^2 */ , 0 /* y^6.z */ , 0 /* y^6 */ , 0 /* y^5.z^3 */ , 0 /* y^5.z^2 */ , 0 /* y^5.z */ , 0 /* y^5 */ , 0 /* y^4.z^4 */ , T2*T2 /* y^4.z^3 */ , 0 /* y^4.z^2 */ , 0 /* y^4.z */ , 0 /* y^4 */ , 0 /* y^3.z^5 */ , 0 /* y^3.z^4 */ , 0 /* y^3.z^3 */ , 0 /* y^3.z^2 */ , 0 /* y^3.z */ , 0 /* y^3 */ , 0 /* y^2.z^6 */ , 2*T2 /* y^2.z^5 */ , 0 /* y^2.z^4 */ , 2*T2*(R2-A2) /* y^2.z^3 */ , 0 /* y^2.z^2 */ , 0 /* y^2.z */ , 0 /* y^2 */ , 0 /* y.z^7 */ , 0 /* y.z^6 */ , 0 /* y.z^5 */ , 0 /* y.z^4 */ , 0 /* y.z^3 */ , 0 /* y.z^2 */ , 0 /* y.z */ , 0 /* y */ , 0 /* z^8 */ , 1 /* z^7 */ , 0 /* z^6 */ , -2*(R2+A2) /* z^5 */ , 0 /* z^4 */ , (R2-A2)*(R2-A2) /* z^3 */ , 0 /* z^2 */ , 0 /* z */ , 0 /* C */ , 0.0001 > 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