home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / DGRAF / FRAIN196.ZIP / FRMTUT.ZIP / FRMTUTOR.FRM next >
Text File  |  1995-02-24  |  7KB  |  329 lines

  1. comment {
  2.   This file is part of the FRMTUT.ZIP package.  It is a compilation of the
  3.   formulas discussed in FRMTUTOR.TXT revision 1.0, and is included so that
  4.   the reader can see how the formulas work.  Please refer to FRMTUTOR.TXT
  5.   for more information.
  6. }
  7.  
  8.  
  9. Mandelbrot (xaxis) { ;The classic Mandelbrot set
  10.   z = 0, c = pixel:
  11.     z = z*z + c
  12.     |z| < 4
  13. }
  14.  
  15.  
  16. frm-A (xaxis) { ;Another formula for the Mandelbrot set
  17.   z = const = pixel:
  18.     z = z^2 + const
  19.     |z| < 4
  20. }
  21.  
  22.  
  23. frm-B { ;A generalized Julia formula
  24.         ;For the traditional Julia algorithm, set FN1() to SQR,
  25.         ;and then try different values for P1
  26.   z = pixel:
  27.     z = fn1(z) + p1
  28.     |z| <= (4 + p2)
  29. }
  30.  
  31.  
  32. frm-C1 {
  33.   z = 0
  34.   c = pixel:
  35.     z = sqr(z) + c
  36.     |z| < 4
  37. }
  38.  
  39.  
  40. frm-C2 { z = 0, c = pixel: z = sqr(z) + c, |z| < 4 }
  41.  
  42.  
  43. Cardioid { ;author not listed
  44.   z = 0, x = real(pixel), y=imag(pixel),
  45.   c=x*(cos(y)+x*sin(y)):
  46.   z=sqr(z)+c,
  47.   |z| < 4
  48. }
  49.  
  50.  
  51. CGNewtonSinExp (XAXIS) { ;by Chris Green
  52.   ; Use floating point, and set P1 to some positive value.
  53.   z=pixel:
  54.   z1=exp(z),
  55.   z2=sin(z)+z1-z,
  56.   z=z-p1*z2/(cos(z)+z1),
  57.   .0001 < |z2|
  58. }
  59.  
  60.  
  61. Mutantbrot { ;A mutation of the classic Mandelbrot set
  62.   z = 0, c = pixel:      ;standard initialization section
  63.     z = z*z + c + sin(z) ;mutated iterated section
  64.     |z| < 4              ;standard bailout test
  65. }
  66.  
  67.  
  68. speed-A { ;Demonstrates potential for speed-up
  69.   z = 0:
  70.     z = z*z + sin(pixel)
  71.     |z| < 4
  72. }
  73.  
  74.  
  75. speed-B { ;variation of speed-A showing one speed-up technique
  76.   z = 0, sinp = sin(pixel):
  77.     z = z*z + sinp
  78.     |z| < 4
  79. }
  80.  
  81.  
  82. IfThen-A1 { ;Demonstrates that the order of expressions can make a
  83.           ;difference.  In this example, the assignment is performed
  84.           ;BEFORE the comparison.
  85.   z = c = pixel:
  86.     (z < 0) * (z = fn1(z) + c)
  87.     (0 <= z) * (z = fn2(z) + c)
  88.     |z| < 4
  89. }
  90.  
  91.  
  92. IfThen-A2 { ;Functional equivalent of IfThen-A2
  93.   z = c = pixel:
  94.     z = fn1(z) + c
  95.     z = fn2(z) + c
  96.     |z| < 4
  97. }
  98.  
  99.  
  100. IfThen-A3 { ;Another equivalent of IfThen-A1
  101.   z = c = pixel:
  102.     z = fn2(fn1(z) + c) + c
  103.     |z| < 4
  104. }
  105.  
  106.  
  107. IfThen-B1 { ;In this formula, the comparison is performed BEFORE the
  108.           ;assignment, but there's still a subtle flaw.
  109.   z = c = pixel:
  110.     (z = fn1(z) + c) * (z < 0)
  111.     (z = fn2(z) + c) * (0 <= z)
  112.     |z| < 4
  113. }
  114.  
  115.  
  116. IfThen-B2 { ;Functional equivalent of IfThen-B1
  117.   z = c = pixel:
  118.     z = (fn1(z) + c) * (z < 0)
  119.     z = (fn2(z) + c) * (0 <= z)
  120.     |z| < 4
  121. }
  122.  
  123.  
  124. IfThen-C1 { ;What we REALLY had in mind.
  125.   z = c = pixel:
  126.     neg = fn1(z) * (z < 0)
  127.     pos = fn2(z) * (0 <= z)
  128.     z = neg + pos + c
  129.     |z| < 4
  130. }
  131.  
  132.  
  133. IfThen-C2 { ;An alternate version of IfThen-C1
  134.   z = c = pixel:
  135.     z = (fn1(z) * (z < 0)) + (fn2(z) * (0 <= z)) + c
  136.     |z| < 4
  137. }
  138.  
  139.  
  140. bailout-A { ;Hard coded bailout value
  141.   ;p1 = parameter (default 0,0)
  142.   z = pixel, c = fn1(pixel):
  143.     z = fn2(z*z) + c + p1
  144.     |z| < 4
  145. }
  146.  
  147.  
  148. bailout-B { ;Variable default -- additive
  149.   ;p1 = parameter (default 0,0)
  150.   ;p2 = bailout adjustment value (default 0,0)
  151.   test = (4 + p2)
  152.   z = pixel, c = fn1(pixel):
  153.     z = fn2(z*z) + c + p1
  154.     |z| < test
  155. }
  156.  
  157.  
  158. bailout-C { ;Variable default -- conditional logic
  159.   ;This formula requires floating-point
  160.   ;p1 = parameter (default 0,0)
  161.   ;p2 = bailout   (default 4,0)
  162.   ;The following line sets test = 4 if real(p2) = 0, else test = p2
  163.   test = (4 * (p2 <= 0)) + (p2 * (0 < p2))
  164.   z = pixel, c = fn1(pixel):
  165.     z = fn2(z*z) + c + p1
  166.     |z| < test
  167. }
  168.  
  169.  
  170. fibo-A { ;Fibonacci / Mandelbrot hybrid
  171.   z = oldz = c = pixel:
  172.     temp = z
  173.     z = z * oldz + c
  174.     oldz = temp
  175.     |z| < 4
  176. }
  177.  
  178.  
  179. fibo-B { ;Mutation of fibo-A
  180.   z = oldz = c = pixel:
  181.     temp = z
  182.     z = fn1(z * oldz) + c
  183.     oldz = temp
  184.     |z| < 4
  185. }
  186.  
  187.  
  188. inandout01 { ;Bradley Beacham  [74223,2745]
  189.   ;p1 = Parameter (default 0), real(p2) = Bailout (default 4)
  190.   ;The next line sets test=4 if real(p2)<=0, else test=real(p2)
  191.   test = (4 * (real(p2)<=0) + real(p2) * (0<p2))
  192.   z = oldz = pixel, c1 = fn1(pixel), c2 = fn2(pixel):
  193.     a = (|z| <= |oldz|) * (c1) ;IN
  194.     b = (|oldz| < |z|)  * (c2) ;OUT
  195.     oldz = z
  196.     z = fn3(z*z) + a + b + p1
  197.     |z| <= test
  198. }
  199.  
  200.  
  201. dissected-A { ;A dissected Mandelbrot
  202.   z = 0, c = pixel:
  203.     x = real(z), y = imag(z)   ;isolate real and imaginary parts
  204.     newx = x*x - y*y           ;calculate real part of z*z
  205.     newy = 2*x*y               ;calculate imag part of z*z
  206.     z =  newx + flip(newy) + c ;reassemble z
  207.     |z| < 4
  208. }
  209.  
  210.  
  211. dissected-B { ;A mutation of "dissected-A"
  212.   z = 0, c = pixel, k = 2 + p1:
  213.     x = real(z), y = imag(z)
  214.     newx = fn1(x*x) - fn2(y*y)
  215.     newy = k*fn3(x*y)
  216.     z =  newx + flip(newy) + c
  217.     |z| < 4
  218. }
  219.  
  220.  
  221. shifter { ;Use a counter to shift algorithms
  222.   z = c = pixel, iter = 1, shift = p1, test = 4 + p2:
  223.     lo = (z*z) * (iter <= shift)
  224.     hi = (z*z*z) * (shift < iter)
  225.     iter = iter + 1
  226.     z = lo + hi + c
  227.     |z| < test
  228. }
  229.  
  230.  
  231. sym-A { ;Non-symmetrical fractal
  232.   z = c = pixel, k = (2.5,0.5):
  233.     z = z^k + c
  234.     |z| < 4
  235. }
  236.  
  237.  
  238. sym-B (xaxis) { ;Sym-A with symmetry declared in error
  239.   z = c = pixel, k = (2.5,0.5):
  240.     z = z^k + c
  241.     |z| < 4
  242. }
  243.  
  244.  
  245. frm-D1 { ;Unparsable expression ignored
  246.   z = c = pixel:
  247.     z = z*z + sin z + c
  248.     |z| < 4
  249. }
  250.  
  251.  
  252. frm-D2 { ;fixed version of frm-D1
  253.   z = c = pixel:
  254.     z = z*z + sin(z) + c
  255.     |z| < 4
  256. }
  257.  
  258.  
  259. weirdo { ;Mandelbrot with no bailout test
  260.   z = c = pixel:
  261.   z = z*z + c
  262. }
  263.  
  264. ghost { ;Demonstrates strange parser behavior
  265.         ;To see effect, use floating point and make sure
  266.         ;FN2() is not IDENT
  267.   z = oldz = c1 = pixel, c2 = fn1(pixel)
  268.   tgt = fn2(pixel), rt = real(tgt), it = imag(tgt):
  269.     oldx = real(oldz) - rt
  270.     oldy = imag(oldz) - it
  271.     olddist = (oldx * oldx) + (oldy * oldy)
  272.     x = real(z) - rt
  273.     y = imag(z) - it
  274.     dist = (x * x) + (y * y)
  275.     a = (dist <= olddist) * (c1)
  276.     b = (olddist < dist)  * (c2)
  277.     oldz = z
  278.     z = z*z + a + b
  279.     |z| <= 4
  280. }
  281.  
  282. ghostless-A { ;One solution to the ghost problem  -- reorder expressions
  283.   z = oldz = c1 = pixel, c2 = fn1(pixel)
  284.   tgt = fn2(pixel), rt = real(tgt), it = imag(tgt):
  285.     oldx = real(oldz) - rt
  286.     oldy = imag(oldz) - it
  287.     olddist = (oldx * oldx) + (oldy * oldy)
  288.     x = real(z) - rt
  289.     y = imag(z) - it
  290.     dist = (x * x) + (y * y)
  291.     a = (c1) * (dist <= olddist) ;Reverse order of value and comparison
  292.     b = (c2) * (olddist < dist)  ;Ditto
  293.     oldz = z
  294.     z = z*z + a + b
  295.     |z| <= 4
  296. }
  297.  
  298. ghostless-B { ;Another solution to the ghost problem -- reinitialize
  299.   z = oldz = c1 = pixel, c2 = fn1(pixel)
  300.   tgt = fn2(pixel), rt = real(tgt), it = imag(tgt):
  301.     oldx = real(oldz) - rt
  302.     oldy = imag(oldz) - it
  303.     olddist = (oldx * oldx) + (oldy * oldy)
  304.     x = real(z) - rt
  305.     y = imag(z) - it
  306.     dist = (x * x) + (y * y)
  307.     a = b = 0                    ;Make sure a & b are set to zero
  308.     a = (dist <= olddist) * (c1)
  309.     b = (olddist < dist) * (c2)
  310.     oldz = z
  311.     z = z*z + a + b
  312.     |z| <= 4
  313. }
  314.  
  315.  
  316. ghostless-C { ;Yet another solution -- simplify!
  317.   z = c1 = pixel, c2 = fn1(pixel), olddist = 100
  318.   tgt = fn2(pixel), rt = real(tgt), it = imag(tgt):
  319.     x = real(z) - rt
  320.     y = imag(z) - it
  321.     dist = (x * x) + (y * y)
  322.     a = (dist <= olddist) * (c1)
  323.     b = (olddist < dist)  * (c2)
  324.     olddist = dist
  325.     z = z*z + a + b
  326.     |z| <= 4
  327. }
  328.  
  329.