NB. J Script for creating High Dimensional Sierpinski Fractals
NB. by Gabriel Brisson and Cliff Reiter
NB. script revised August 2002
NB. requires FVJ2 materials from http://www.lafayette.edu/~reiterc/j/index.html
NB. and
NB. the image3 addon (and J itself) from http://www.jsoftware.com
NB. and POVRAY from http://www.povray.org
NB. illustrates how the 3d version may be created
NB.
NB. Run all lines except last two; run povray on sw.ini,
NB. then run the last two lines
load 'fvj2\povkit+.ijs'
load 'trig'
NB. modify the paths as appropriate
path=:'\r\mvp\sier_word\'
ppath=:path,'pov\'
pfn=: ppath,'sw.pov'
pfi=: ppath,'sw.ini'
view_pars_sier=: 0 : 0
// set viewing parameters
camera{
// location <-12,40,10>
location <42*cos(2*pi*clock),42*sin(2*pi*clock),12>
angle 4
up <0,0,1>
right <0,1.333333,0>
sky <0,0,1>
look_at<0,0,0.9>
}
#default{finish{ambient 0.7}}
object{light_source{<-100,100,50> color rgb<2,2,2>}}
object{light_source{<100,-50,50> color rgb<1,1,1>}}
background {color rgb<1,1,1>}
)
ini_file=:0 : 0
Initial_Frame=0
Final_Frame=71
Subset_Start_Frame=0
Subset_End_Frame=71
Input_File_Name=sw.pov
Cyclic_animation=On
Pause_when_Done=Off
Output_File_Type=S
Sampling_Method=1
Antialias_Threshold=0.5
Antialias_Depth=2
Jitter=Off
Test_Abort_Count=100
)
root=: +./\.@(] ~: {:) # ]
admis=: *.&('_'&~:@{.@(_1&{.)) root
unit=: % +/&.(*:"_)
mk_sw=: 3 : 0
(0.02 % 1 4.5) mk_sw y.
:
'n maxl'=:y.
'r0 r1'=: x.
alf=: '_',n{.'abcdefghijk'
]fml=: 0,([: unit cos,sin,1:)"0 (2p1&% * i.) n
pos=: {&fml@(alf &i.) +/@:* 0.5&^@i.@#
rr=: ^(^.r1%r0)%<:maxl
radius=: r0&*@(rr&^)@#@root
c=:0,hue1 (i.%])n
color=: {&c@(alf&i.)@{:
fmtw=: color fmtcyl pos@root , pos , radius
w=: ,{maxl#<alf
aw=: (admis&> # ])w
if. -. fexist pfi do. ini_file fwrites pfi end.
view_pars_sier fwrites pfn
(fmtw&> aw) fappends pfn
)
NB. create a 3-d fractal
(0.02 % 1 3.5) mk_sw 3 7
NB. run povray on pfi (sw.ini presumably)
NB. Then continue:
fs=:'sw*.bmp' files_in ppath NB. frame names
9 fseq_to_jpeg_mov fs;'mov' ch_ext pfn NB. make movie