Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create a random fractal solenoid, as shown in http://paulbourke.net/fractals/solenoid/
- # using the G'MIC script language.
- solenoid3d :
- -torus3d 100,10,64,32 -col3d. ${-RGB} -nm. 0,0,0,1,0,0,0,1,0,0,0,1,100,10 # Create initial torus
- -repeat 5 # Number of scales
- subd={round(1.25^-($>+1)*[64,32])} # Torus resolution for this scale (decreasing).
- col=${-RGB} # Same random color for a single scale
- N={round(u(4,8))} # Random number of subdivision for this scale
- -repeat $! -l[$<] # For each existing torus, let's add children !
- nm={n}
- -if {narg($nm)>1}
- X={([$nm])[0,3]} # Current center
- R={([$nm])[3,9]} # Current rotation matrix
- r={([$nm])[12,2]} # Current radii
- nr={[$r]/2.5} # New radii (decreasing).
- -repeat $N # Start the loop to add children
- ang={$>*360/$N}
- nX={rad=$ang*pi/180;[$X]+([$r])[0]*[$R]*[cos(rad),sin(rad),0]} # New center
- nR={mul([$R],mul(rot(0,0,1,$ang),rot(1,0,0,90),3),3)} # New rotation matrix
- -torus3d $nr,$subd nbp={i[6]} # Add new torus
- -sh. 8,{8+3*$nbp-1},0,0 -r. 3,$nbp,1,1,-1 3,3,1,1,$nR -transpose. -m*[-2,-1] -rm. # Small hack to orient 3d torus with matrix nR.
- -+3d. $nX -col3d. $col # Translate torus and assign color
- -nm. $nX,$nR,$nr # Associate its new parameters.
- -done
- -nm[0] 0 # Disable recursion for the parent torus in next iterations
- -endif
- -endl -done
- -done
- -+3d # Add all 3d object togethers
- -m3d 5 -db3d 0 -md3d -1 # Define reasonable rendering mode
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement