#version 3.7; global_settings { assumed_gamma 1.0 } #default { finish { ambient 0.1 diffuse 0.9 } } camera { perspective angle 75 location <0, 0, -1> right x*image_width/image_height look_at <0, 0, 0> } light_source {< 3000,3000,-3000> color 1} sky_sphere { pigment { gradient <0,1,0> color_map { [0.00 rgb <0.6,0.7,1.0>] [0.35 rgb <0.1,0.0,0.8>] [0.65 rgb <0.1,0.0,0.8>] [1.00 rgb <0.6,0.7,1.0>] } scale 2 } } plane { y, -1 texture { pigment { checker color rgb <1,1,1>*1.2 color rgb <0.25,0.15,0.1>*0 } //normal { bumps 0.75 scale 0.025} //finish { phong 0.1} } } #include "Math.inc" #declare TWO_PI = 2 * pi; #declare iNx = 28; #declare iNy = 32; #declare iXmin = 20; #declare iSym = 5; #declare bInside = true; #declare bSoft = true; #declare bDetails = true; #declare fZoom = 1; #declare iW = 2; #declare iH = 2; #declare iSx = 4; #declare iSy = 4; #declare iWidth = 300; #declare iHeight = 300; #declare iMouseX = 200; #declare iMouseY = 200; #macro mag(fX, fY) vlength() // return #end #macro dist(fX1, fY1, fX2, fY2) VDist(, ) //return #end #macro draw() #for (i, 0, iNy - 1) #local fY = i * TWO_PI/iNy; #for (j, iXmin * iSx, iNx * iSx - 1) #local fX1 = j * TWO_PI/iNx/iSx; #local fX2 = (j + 1) * TWO_PI/iNx/iSx; lines(fn(fX1, fY), fn(fX2, fY)) #end #end #for (i, iXmin, iNx) #local fX = i * TWO_PI/iNx; #for (j, 0, iNy * iSy - 1) #local fY1 = j * TWO_PI/iNy/iSy; #local fY2 = (j + 1) * TWO_PI/iNy/iSy; lines(fn(fX, fY1), fn(fX, fY2)) #end #end #end #macro lines(faaP1, faaP2) #local iL = iSym; //getn(faaP1); #for (i, 0, iL - 1) #local fX1 = faaP1[i][0]; #local fY1 = faaP1[i][1]; #local fX2 = faaP2[i][0]; #local fY2 = faaP2[i][1]; #local fD = dist(fX1, fY1, fX2, fY2); #local fC = fD * 8; #if (fC < 255) //stroke(0, 255 - fC) //line(fX1, fY1, fX2, fY2) sphere { , 0.005 pigment {color rgb x} } #end #end #end // this is where the magic happens ... #macro fn(fX, fY) #local faaP = array[iSym][2]; #local fX1 = exp(fX) * cos(fY) + (iWidth/2 - iMouseX); #local fY1 = exp(fX) * sin(fY) + (iHeight/2 - iMouseY); #local fD = fZoom; #if (bInside = 1) #local fD = fD * 0.05 * pow(iSym, 1.5) * pow(mag(fX1, fY1), 1/iSym); #else #local fD = fD * 10 / log(iSym) * pow(mag(fX1, fY1), -1/iSym); #end #local fArg = atan2(fX1, fY1) * -1/iSym; #for (i, 0, iSym - 1) #local fX2 = fD * cos(fArg + i * TWO_PI/iSym); #local fY2 = fD * sin(fArg + i * TWO_PI/iSym); #local faaP[i][0] = iW * fX2/TWO_PI; #local faaP[i][1] = iH * fY2/TWO_PI; #end faaP //return #end draw()