clearglobals(); // cheeryMonday(80 seconds*34FPS=2720 frames) 53frameAnimation@34FPS 53/34=1.5588 sec // twisting 89@40 or 69@31 89/40=2.225 sec 69/31=2.2258 sec starttime = tickseconds(); dir="G:\pulser\pics\"; // drop pics here totalpics=2720; PreRollPics=300; // extra animation at begin position; the video is made in reverse, so these become tail end // row/col center and +/- eps in mandelbrot space rplace=-0.55; cplace=-0.55; eps=3.5e-3; scale=3;// 1920*1080 scale factor // sheet geometry delta=2*2*2*3*3; span= 2*2*2; distance=-100; grid = 1/12; // pulse cycle resolution nphase=40; colorlookup = [=>.]; global:phase=2*pi(); zValueFunction = Function( {x, y}, // the function to plot. the sheet color assumes the result is between -1 and +1. x -= grid / 2; y -= grid / 2; 20 * sin(global:phase + Sqrt( x * x + y * y ) / 3 ) / ( x * x + y * y )^.3; ); colorFunction = Function( {x, y}, {m = colorlookup[x * 1e9 + y*1e3]}, If( Is Missing( m ), m = Mandelbrot( 500, 0, Interpolate( x, -delta, cplace - eps, delta, cplace + eps ), Interpolate( y, -delta, rplace - eps, delta, rplace + eps ) ); m = Heat Color( (m / 500) ^ .3, "jet" ); colorlookup[x * 1e9 + y*1e3] = m; ); m; ); normallookup = [=>.]; normalFunction = Function( {x, y}, {deltaq = grid/1024, qx, qy, qz, px, py, pz, nx, ny, nz, len, zxy, color, m = normallookup[x * 1e9 + y*1e3]}, if(!islist(m), color = colorFunction( x, y ); zxy = zValueFunction( x, y ); // calculate the normal using a delta slope at the point qx = deltaq; qy = 0; qz = zValueFunction( x + deltaq, y ) - zxy; px = 0; py = deltaq; pz = zValueFunction( x, y - deltaq ) - zxy; nx = py * qz - pz * qy; ny = pz * qx - px * qz; nz = px * qy - py * qx; // normalize the normal vector len = Sqrt( nx * nx + ny * ny + nz * nz ); nx /= len; ny /= len; nz /= len; normallookup[x * 1e9 + y*1e3] = evallist({nx,ny,nz,color,zxy});// ,// else {nx,ny,nz,color,zxy} = m;// ); sheet << Normal( nx, ny, nz ); sheet << Color( color ); sheet << Vertex( x, y, zxy ); ); makesheet = Function( {}, {sheetx, xleft, xright, y, ybot, ytop}, sheet = Scene Display List(); // creates a display list, which will hold a list of commands sheet << Material( Front_and_Back, Specular, .4, .4, .4, .1 ); sheet << Material( Front_and_Back, Shininess, 120 ); sheet << Material( Front_and_Back, Ambient_and_Diffuse, 1, 1, 1, .1 ); sheet << Enable( Color_Material ); // allows the color commands to update the material property sheet << Begin( QUADS ); // not a quad strip. this uses 4 points per quad so all 4 point can have the same normal. For( x = -delta + grid, x < delta, x += grid, if(x==floor(x),write(" ",x)); //If( Mod( x, span ) == 0, Continue() ); xleft = x; xright = x + grid; For( y = -delta + grid, y < delta, y += grid, //If( Mod( y, span ) == 0, Continue() ); ybot = y; ytop = y + grid; normalFunction( xleft, ytop ); normalFunction( xright, ytop ); normalFunction( xright, ybot ); normalFunction( xleft, ybot ); ); ); sheet << End(); // ends the quads sheet << Disable( Color_Material ); sheet;//return ); images=0; scene = Scene Box( 1920*scale, 1080*scale ); scene<.]; // reset normals for next phase phasesheet = makesheet(); For( a = iphase, a <= totalpics+PreRollPics, a = a + nphase, // a loop to rotate the display list; a gets scaled below, so its not really in degrees scene << Clear; scene << Light( Light0, DIFFUSE, .6, .6, .6, 1 ); scene << Light( Light0, SPECULAR, 1, 1, 1, 1 ); scene << Enable( Lighting ); // any surfaces rendered after this will respond to the light scene << Enable( Light0 ); // turn on one of the eight available lights (0...7) scene << LightModel( LIGHT_MODEL_TWO_SIDE, 1 ); scene << Perspective( 45, -distance / 10, -10 * distance ); scene << Translate( 0.0, 0.0, distance ); scene << Light( Light0, Position, -100/*left*/, 100/*top*/, 1000, 1 ); scene << Rotate( if(a<=PreRollPics,0,(a-PreRollPics) * .07), 1.0, 0.0, 0.0 ); // spin around the X axis scene << Rotate( if(a<=PreRollPics,0,(a-PreRollPics) * .11), 0.0, 1.0, 0.0 ); // and the Y axis scene << Rotate( if(a<=PreRollPics,0,(a-PreRollPics) * .13), 0.0, 0.0, 1.0 ); // and the Z axis scene << CallList( phasesheet ); scene << savepicture( dir || "p" || Char( 1e7+a ) || ".jpg", "jpg" ); now=tickseconds(); images+=1; write("\!n phase ", char(iphase / nphase,7), " image ", a, " sec/img ", char((now-starttime)/images,7) ); Wait( 0.01 ); );//a );//ph