Creating a Mandala
- To: mathgroup at smc.vnet.net
- Subject: [mg102046] Creating a Mandala
- From: BenT <brtubb at pdmusic.org>
- Date: Mon, 27 Jul 2009 06:07:22 -0400 (EDT)
I've attempted to convert a Decimal BASIC 7 program to Mathematica 7, but can't get the graphics to work as expected. Can anyone help? The source and my conversion code follows: <--- Decimal BASIC source ---> REM MANDALA1.bas REM from REM http : // utenti.quipo.it/base5/mumeri/mandala.htm OPTION ANGLE DEGREES LET q = 2^20 LET fraz = 5 LET ng = 3 LET q1 = 250 LET f = (q1/q) LET cr = 5 SET WINDOW - q1 - cr, q1 + cr, -q1 - cr, q1 + cr LET xv = 0 LET yv = 0 LET ro = q/fraz*ng LET th = 0 LET xv = fraz/ng*f*ro*COS (th) LET yv = 0 FOR i = 1 TO q/fraz*ng LET n = n + i LET t = MOD (n, q) IF t = 0 THEN LET t = q LET th = t*(360/(q)) LET x = fraz/ng*f*ro*COS (th) LET y = fraz/ng*f*ro*SIN (th) SET LINE COLOR MOD (i, fraz) + 1 PLOT LINES : xv, yv; x, y LET xv = x LET yv = y NEXT i END <--- Mathematica Code Conversion Attempt ---> q=2^20; fraz=5; ng=3; q1=250; f=q1/q; cr=5; xv=0; yv=0; ro=q/fraz*ng; th=0; xv=fraz/ng*f*ro*Cos[th Degrees]; yv=0; Graphics[ For[i=1,i<=q/fraz*ng,i++, n=n+i; t=Mod[n,q]; If[t==0,t=q]; th=t*360/q; x=fraz/ng*f*ro*Cos[th Degree]; y=fraz/ng*f*ro*Sin[th Degree]; {{Black,Green,Blue,Red,Yellow}[[Mod[i,fraz]+1]], Line[{xv,yv},{x,y}]} xv=x; yv=y; ] ,ImageSize->{Abs[-q1-cr-(q1+cr)],Abs[-q1-cr-(q1+cr)]} ] I'm not sure how to allow the "Line" function to work multiple times within the Graphics function without creating its ouptut in multiple ouptut cells instead of just one as needed.