#include "colors.inc" #include "include\stones.inc" #include "textures.inc" /* Pov3 Parametric equation - Treefoil knot. With smooth triangles. */ #version 3.0 global_settings { assumed_gamma 1.0 } #declare counter = 1 #declare umin = 0 //endpoints in the #declare umax = 4*pi //parametric rectangle #declare vmin = 0 #declare vmax = 2*pi #declare uiter = 80 //number of steps #declare viter = 12 //this is max fot 4mb ram #declare iu = (umax-umin)/uiter //increment per step #declare iv = (vmax-vmin)/viter #declare a=1 #declare b=0.3 #declare c=0.5 #declare d=0.3 union{ #declare uu = umin #while (uu<=umax) //outer loop #declare vv = vmin #while (vv<=vmax) //inner loop //POINTS #declare r=a+b*cos(1.5*uu) #declare xx=r*cos(uu) #declare yy=r*sin(uu) #declare zz=c*sin(1.5*uu) #declare dx=-1.5*b*sin(1.5*uu)*cos(uu)-(a+b*cos(1.5*uu))*sin(uu) #declare dy=-1.5*b*sin(1.5*uu)*sin(uu)+(a+b*cos(1.5*uu))*cos(uu) #declare dz=1.5*c*cos(1.5*uu) #declare qn=vnormalize() #declare qvn=vnormalize() #declare ww=vcross(qn,qvn) #declare x1=xx+d*(qvn.x*cos(vv)+ww.x*sin(vv)) //Calculate the #declare y1=yy+d*(qvn.y*cos(vv)+ww.y*sin(vv)) //four points in #declare z1=zz+d*ww.z*sin(vv) //the rectangle defined #declare nx1=qvn.x*cos(vv)+ww.x*sin(vv) #declare ny1=qvn.y*cos(vv)+ww.y*sin(vv) #declare nz1=ww.z*sin(vv) #declare vv=vv+iv //by uu,uu+iu,vv,vv+iv #declare r=a+b*cos(1.5*uu) #declare xx=r*cos(uu) #declare yy=r*sin(uu) #declare zz=c*sin(1.5*uu) #declare dx=-1.5*b*sin(1.5*uu)*cos(uu)-(a+b*cos(1.5*uu))*sin(uu) #declare dy=-1.5*b*sin(1.5*uu)*sin(uu)+(a+b*cos(1.5*uu))*cos(uu) #declare dz=1.5*c*cos(1.5*uu) #declare qn=vnormalize() #declare qvn=vnormalize() #declare ww=vcross(qn,qvn) #declare x2=xx+d*(qvn.x*cos(vv)+ww.x*sin(vv)) //Calculate the #declare y2=yy+d*(qvn.y*cos(vv)+ww.y*sin(vv)) //four points in #declare z2=zz+d*ww.z*sin(vv) //the rectangle defined #declare nx2=qvn.x*cos(vv)+ww.x*sin(vv) #declare ny2=qvn.y*cos(vv)+ww.y*sin(vv) #declare nz2=ww.z*sin(vv) #declare uu=uu+iu #declare r=a+b*cos(1.5*uu) #declare xx=r*cos(uu) #declare yy=r*sin(uu) #declare zz=c*sin(1.5*uu) #declare dx=-1.5*b*sin(1.5*uu)*cos(uu)-(a+b*cos(1.5*uu))*sin(uu) #declare dy=-1.5*b*sin(1.5*uu)*sin(uu)+(a+b*cos(1.5*uu))*cos(uu) #declare dz=1.5*c*cos(1.5*uu) #declare qn=vnormalize() #declare qvn=vnormalize() #declare ww=vcross(qn,qvn) #declare x3=xx+d*(qvn.x*cos(vv)+ww.x*sin(vv)) //Calculate the #declare y3=yy+d*(qvn.y*cos(vv)+ww.y*sin(vv)) //four points in #declare z3=zz+d*ww.z*sin(vv) //the rectangle defined #declare nx3=qvn.x*cos(vv)+ww.x*sin(vv) #declare ny3=qvn.y*cos(vv)+ww.y*sin(vv) #declare nz3=ww.z*sin(vv) #declare vv=vv-iv #declare r=a+b*cos(1.5*uu) #declare xx=r*cos(uu) #declare yy=r*sin(uu) #declare zz=c*sin(1.5*uu) #declare dx=-1.5*b*sin(1.5*uu)*cos(uu)-(a+b*cos(1.5*uu))*sin(uu) #declare dy=-1.5*b*sin(1.5*uu)*sin(uu)+(a+b*cos(1.5*uu))*cos(uu) #declare dz= 1.5*c*cos(1.5*uu) #declare qn=vnormalize() #declare qvn=vnormalize() #declare ww=vcross(qn,qvn) #declare x4=xx+d*(qvn.x*cos(vv)+ww.x*sin(vv)) //Calculate the #declare y4=yy+d*(qvn.y*cos(vv)+ww.y*sin(vv)) //four points in #declare z4=zz+d*ww.z*sin(vv) //the rectangle defined #declare nx4=qvn.x*cos(vv)+ww.x*sin(vv) #declare ny4=qvn.y*cos(vv)+ww.y*sin(vv) #declare nz4=ww.z*sin(vv) #declare uu=uu-iu //CURVATURE as difference between normals // #declare ucur = vlength(vnormalize(n6)-vnormalize(n5))/2 // #declare vcur = vlength(vnormalize(n2)-vnormalize(n5))/2 //TRIANGLES object{ smooth_triangle{ ,, ,, , } texture{ T_Stone20 } } object{ smooth_triangle{ ,, ,, , } texture{ T_Stone20 } } #declare vv = vv+iv #end //inner loop #declare uu = uu+iu #debug concat("Looping on ",str(counter,0,-1)," of ",str(uiter,0,-1),"\n") #declare counter = counter + 1 #end //outer loop //rotate <90,0,0> //This is just changing the //rotate <0,90,0> //coordinate system. } //Lights, camera, action camera { location < 1.5, 2.25,-3.75> direction 1*z look_at < 0, 0, 0> } light_source { <0, 0,-5> color rgb 1 } light_source { <5, 5, -4> color rgb 1 } object {box{-6,6 inverse}pigment{color rgb 0.8}}