#version 3.7;
global_settings { assumed_gamma 2. }
#include "colors.inc"
#include "metals.inc"
#include "glass.inc"
#include "transforms.inc" // various geometric transformation macros
camera { orthographic location <0,0,-30> look_at<0.,-0.0,0> right 1*x angle 30} // perspective //right 16/9*x // borromee
light_source { <-20,40,-40>*80 color rgb <1,1,1> // shadowless
// area_light <1,0,0>, <0,0,1>,4, 4 // jitter
}
light_source { <10,20,-30>*80 color White shadowless} // }
//light_source { <10,-10,-20>*200 color rgb <1,1,1> shadowless}
background{ White*0.8 } // Black } //
// 0.45
#declare monfinish=finish{ ambient 0.1 diffuse 0.7 reflection 0.1 roughness 0 phong 1. phong_size 4};
#macro tex(col) texture{ pigment{col} finish{monfinish} } #end
//===================================================
#declare tabcol=array[11]{Blue,Red,Yellow*0.9,SeaGreen,Magenta,Cyan,Khaki,Pink,Aquamarine,Copper*0.8,Gold};
#declare R=4.5;
//------------
declare coef=0.8;
//#declare r=0.3 ; #declare a=2.5*coef; #declare b=1*coef; #declare c=3*coef; // borromee courbe 2
//#declare r=0.2 ; #declare a=2*coef; #declare b=1.5*coef; #declare c=3*coef; // carré courbe 2
#declare r=0.5 ; #declare a=3*coef; #declare b=1.8*coef; #declare c=5*coef; // cercle courbe 2
#macro courbe(uu) #end
#macro courbe(uu) #end
//===================================================
#declare borromee=union{
union{ #local n=200; #local pas=2*pi/n ;
#for(i,0,n-1,1) cylinder{courbe(i*pas),courbe((i+1)*pas),r } sphere{courbe(i*pas),r } #end //
pigment{Yellow*0.9} finish{monfinish}
}
torus{ 3,r pigment{ Blue} finish{monfinish} rotate 45*z translate <0,0,2.4*c> }
torus{ 3,r pigment{ Red} finish{monfinish} rotate -45*z translate <0,0,-2.4*c> }
}
//===================================================
#macro partie()
union{ #local n=200; #local pas=2*pi/n ;
#for(i,0,n-1,1) cylinder{courbe(i*pas),courbe((i+1)*pas),r } sphere{courbe(i*pas),r } #end //
}
#end
#declare d=c*0.8; // courbe 1 // c*0.7; // courbe 2 //
#macro trace_cas(N,n) //------- N =1 tracé en carré, N =2 tracé en cercle, N =3 tracé en segment -------
//------- n= nombre de composants du noeud
#if(N=1)
// =============== carré de courbes =================
#declare r=0.3 ; #declare a=1.5*coef; #declare b=1.*coef; #declare c=3.5*coef; // carré courbe 2
#declare d=0.8*c;
#declare basex=union{ object { partie() rotate -45*z rotate 90*y translate d*x} };
// #declare n=3; // --- nombre de composants du noeud avant inclusion dans trace_cas
#declare mp=2; // --- modulo pour les couleurs
#declare cotex=
union{ #for(i,0,n-1,1) object { basex translate 2*i*d*x pigment{tabcol[mod(i,mp)]} finish{monfinish}} #end };
#declare cotey=
union{ #for(i,0,n-1,1) object { basex translate 2*i*d*x pigment{tabcol[mod(i+1,mp)]} finish{monfinish}} #end
rotate 90*z rotate 90*y translate <-0.7,-0.35,0>};
#declare demi=
union{ object{cotex} object{cotey } }
//-------------------------------------
union{ object{demi} object{demi rotate 180*z translate <4.1,4.5,0>*n }
translate <-1,-1,0>*2*n // 2*(n-1/2)*d*<-1.1,2.1,0> //
scale 0.8 //
rotate <-7,8,0>
}
#elseif(N=2)
// =============== cercle de courbes =================
#declare R=n-0.5; //---- adapter éventuellement selon la valeur de n
#declare base1= object { partie() rotate 45*z rotate 90*x rotate (20-n)*z translate R*x pigment{Red} finish{monfinish}} // SeaGreen pigment {rgb <.93,.182,.11>}
#declare base2= object{ partie() rotate 45*z rotate 90*x rotate (20-n)*z translate R*x pigment{ Yellow*0.9} finish{monfinish}} // Orange pigment{Blue*0.9}
union{
//---- #declare n=10; // --- nombre de composants du noeud avant inclusion dans trace_cas
#declare ang=360/n;
#if(mod(n,2)=0)
#for(i,0,n-1,1) object{base1 rotate 2*i*ang*z } object{base2 rotate (2*i+1)*ang*z } #end
#else
#for(i,0,n-1,1) object{base1 rotate i*ang*z } #end
#end
scale 0.9
rotate <-20,-20,0>
}
#elseif(N=3)
// =============== segment de courbes =================
#declare basex=union{ object { partie() rotate -45*z rotate 90*y translate d*x pigment{Red} finish{monfinish}} // pigment{Red}
object { partie() rotate -45*z rotate 90*y translate -d*x pigment{Yellow*0.9} finish{monfinish}} // pigment{Blue}
};
#declare basex =object { partie() rotate -45*z rotate 90*y translate d*x } ; // pour couleurs choisies
// #declare n=3; V
union{
// #for(i,0,n-1,1) object { basex translate 4*1/2*d*x } #end // translate 4*i*d*x
#for(i,0,n-1,1) object { basex translate 2*i*d*x tex(tabcol[i]) } #end
torus{1*d,r rotate 90*x translate <(-1*n+2.5)*d,0,0> pigment{Cyan} finish{monfinish}}
torus{1*d,r rotate 0*x translate <(1*n+3.5)*d,0,0> pigment{Cyan} finish{monfinish}} //<(2*n+2.5)*d,0,0>
rotate <-20,0,45>
translate <-1,-1,0>*6 // <-n*d+1,-1.4*d,0> // <-n*d+1.5,-0.5*d,0>*1 //
scale 0.68 //2/(1+n)
}
#end
#end
//============= EXECUTION D'UN TRACE ============================
//------- N =1 tracé en carré, N =2 tracé en cercle, N =3 tracé en segment -------
#declare N=1; //=----- pour N=2 adapter le rayon R du cercle dans trace-cas
object{ trace_cas(2,6) scale 0.8}
text{
ttf "timrom.ttf" "AE" 0.5, 0
scale 1 rotate <-8,8,0>
translate <1,-1.3,-4>*5.5
pigment { White*0.4 }
}