translating code from True Basic to Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg69381] translating code from True Basic to Mathematica
- From: Roger Bagula <rlbagula at sbcglobal.net>
- Date: Sun, 10 Sep 2006 07:19:46 -0400 (EDT)
I did some IFS based on {r,theta} variable iteration
several years back.
One seems to have become a favorite.
Arg[] and ArcTan[] in Mathematica aren't exactly the same function as
Angle() in True Basic!
A delicate lace like fractal that I did several years back is at:
http://local.wasp.uwa.edu.au/~pbourke/fractals/lace/lace.basic
C code is at:
http://local.wasp.uwa.edu.au/~pbourke/fractals/lace/lace.c
My best effort so far at a Mathematica translation is:
Clear[ifs, f1, f2, f3, f4, f]
f1[{x_, y_}] = N[{ -Cos[Arg[x + 1/2 + I*(y + Sqrt[3]/2)]]*
Sqrt[x^2 +
y^2] - 1/
2, -Sin[
Arg[x + 1/2 + I*(y +
Sqrt[3]/2)]]*Sqrt[x^2 + y^2] - Sqrt[3]/2}]/2;
f2[{x_, y_}] = N[{ -Cos[Arg[x + 1/2 +
I*(y - Sqrt[3]/2)]]*Sqrt[x^2 + y^2] -
1/2, -Sin[Arg[x + 1/2 + I*(y -
Sqrt[3]/2)]]*Sqrt[x^2 +
y^2] + Sqrt[3]/2}]/2;
f3[{x_, y_}] = N[{ -Cos[Arg[x - 1 +
I*(y)]]*Sqrt[x^2 + y^2] + 1, -Sin[Arg[x -
1 + I*(y)]]*Sqrt[x^2 + y^2]}]/2;
f4[{x_, y_}] = N[{ -Cos[Arg[x + I*(y)]]*Sqrt[x^2 + y^2], -Sin[Arg[x +
I*(y)]]*
Sqrt[x^2 + y^2]}]/2;
f[x_] := Which[(r = Random[]) <= 1/4, f1[x],
r <= 1/2, f2[x],
r <= 3/4, f3[x],
r <= 1.00, f4[x]]
ifs[n_] := Show[Graphics[{PointSize[.001],
Map[Point, NestList[f, {0, 0.001}, n]]}], AspectRatio -> Automatic]
ifs[10000]