NB. An Open Gl J script file
NB. Creates an image of F_3, the free group on three generators
NB. script by Cliff Reiter, Jan 2004
NB. requires owin+.ijs
NB. available from http:/www.lafayette.edu/~reiterc/j/fvj2/index.html
load 'fvj2\owin+.ijs'
NB. alphabet
]alf=:'abcABC'
NB. list of trivial words
]triv=: (,|."1) 'abc',.'ABC'
NB. adverb to remove trivial words
rmw=:1 : '-. @:(+./@:(+./"1)@:(m.&( E."1"1 _))) # ]'
NB. words of given length with trivial words removed
]w1=:>{<alf
]w2=:triv rmw >,{2#<alf
]w3=:triv rmw >,{3#<alf
#w4=:triv rmw >,{4#<alf
NB. motion of the letters
]letmot=:(,-) =i.-:#alf
NB. colors for the letters
]letcol=:(,-.) =i.-:#alf
NB. position of a word
posw=:0.5&^@i.@# +/ . * {&letmot@(alf&i.)
NB. radius of a word
rad0=:0.1
radr=:0.75
radw=:rad0&*@(radr&^)@#
NB. color of a word
colw=: {&letcol&(alf&i.)@{:
NB. cylinder generated by a word
cylw=: posw@}: , posw , radw
NB. create a open gl window with the 3D free product tree
(0 0 0;20 10 3.5;0 0 1;15) owin 'F_3'
(colw ocyl cylw)"1&> w1;w2;w3;w4
oshow ''