NB. An Open Gl J script file 
NB. Creates an image of the free product of Z_6 and Z_3
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. maximal exponents
me=:6 3 6 3 6

]ale=: [: <@,@{ <@:>:@i."0

ale 2 3

;ale\2 3

#ex0=:;ale\me

NB. want to remove exponents that meet their
NB. maximum except at the first or last position

okq=:*./@}.@}:@:~: {.&me@#

okq 1 1 1

okq 1 1 6

okq 1 3 6

okq 6 1 6

NB. the exponent list we want
#ex=:(okq&> # ]) ex0

NB. circle position
cp=:^@j.@+:@o.@(%/)

cp 1 3

cp 1 2

cp 5 5

NB. relative word position
rr=:0.44
pos0=:fix`(cp@{.)@.(#=1:)
fix=:cp@{. * -.@(rr&*)@<:@pos0@}.
pos0 ,:1 4
pos0 1 4,:1 2

NB. cylinder beginning and end functions
pos0_1=:[: pos0 }: , {: + _1 0"_
pos=: _3&{.@+.@pos0
pos_1=: _3&{.@+.@pos0_1

NB. color/radius of a exponent list
col=: {&(1 0 0,:0 1 0)@(2&|)@#
rad0=:0.1
radr=:0.6
rad=: rad0&*@(radr&^)@#

NB. cylinder associated with the exponent
cyle=: (pos_1 , pos , rad )@:(,. {.&me@#)

NB. create the open gl window and objects
(0 0 0;10 0 0 ;0 0 1;30) owin 'Z_6 * Z_3'
(col ocyl cyle)&> ex
oshow ''