返回列表 回复 发帖
科赫雪花开关项3的代码如下:
KochCurve {
init:
  z = #pixel
  zz=0
  x = real(z)
  y = imag(z)
  sq3 = sqrt(3)
  bool bail2 = false
  bool bail = false
  i = 2
loop:
  i = i + 1
  if i == 2
    arg = atan2(z)
      if (-y + 1/sq3 > 0) && (sq3*x + y + 2/sq3 > 0) \
         && (sq3*x - y - 2/sq3 < 0)
        bail = true
      endif
      if (arg > 5/6*pi) || (arg < -pi/2)
        z = z*exp(1i*4/3*pi)
      endif
      if (arg < pi/6) && (arg > -pi/2)
        z = z*exp(1i*2/3*pi)
      endif
      z = z - 1i*1/sq3

        zz = z
        z = #pixel
      if |x| > 1 || x/sq3 + y - 2*sq3/3 > 0 \
         || x/sq3 + y + 2*sq3/3 < 0 || x/sq3 \
         - y + 2*sq3/3 < 0 || x/sq3 - y - \
         2*sq3/3 > 0
        bail = true
      endif
      if (abs(arg) < pi/6)
        z = z*exp(-1i*pi/2)
      elseif (arg > pi/6) && (arg < pi/2)
        z = z*exp(-1i*5*pi/6)
      elseif (arg > pi/2) && (arg < 5*pi/6)
        z = z*exp(1i*5*pi/6)
      elseif (abs(arg) > 5*pi/6)
        z = z*exp(1i*pi/2)
      elseif (arg < -pi/6) && (arg > -pi/2)
        z = z*exp(-1i*pi/6)
      elseif (arg < -pi/2) && (arg > -5*pi/6)
        z = z*exp(1i*pi/6)
      endif
      z = z + 1i
      z = sq3*z
  elseif i > 2
      oldz = z
      z = zz
      zz = oldz
    z = 3*z
    x = real(z)
    y = imag(z)
    if (y > 0) && (sq3*x - y + sq3 > 0) \
       && (sq3*x + y - sq3 < 0)
      bail2 = true
    endif
    z = z/3
    x = real(z)
    y = imag(z)
    if x < -1/3
      z = 3*z + 2
    elseif x > 1/3
      z = 3*z - 2
    else
      if x < 0
        z = z + 1/3
        z = z*exp(-1i*pi/3)
        z = 3*z - 1
      else
        z = z - 1/3
        z = z*exp(1i*pi/3)
        z = 3*z + 1
      endif
    endif
  endif
bailout:
  bail == false && bail2 == false
default:
  title = "Koch Curve"
  helpfile = "sam-help/kochcurves.htm"
  helptopic = "kcurve"
  magn = 1.5
  center = (0.0002,0)
  maxiter = 50
}
好象是综合前两个开关项,此开关项算起来更繁,更具挑战性,更要有十足耐心与高精度的细致才行。
科赫雪花开关项3,计算量特大,我硬着头皮弄完后,扫出的图不对劲,数据太多了,查都没法查起,等脑子清醒占再弄,也许要放弃了。此分形,我算是服了。
此谢儿宾斯基三角形,原来我与榕老师研究过,榕老师最先造出。原代码太长,且繁杂不堪。今对原代码大势减肥,浓缩成下面代码,再用GSP作之,十分容易,好象效果图没啥两样,大家可对照对照,看看有无问题。
gnd-slope-sierpinski2 {
init:
  z1 = #pixel
  int done = 2
loop:
  IF ((imag(z1)>=.575*real(z1)) && (-.575*real(z1)<=imag(z1)))
    z1 = 2*z1-1i
  ELSEIF (real(z1)<=0)
    z1 = 2*z1+(.8660254, 0.5)
  ELSEIF (real(z1)>0)
    z1 = 2*z1+(-.8660254, 0.5)
  ELSE
    z1 = 2*z1
  ENDIF
  modz = |z1|
  done = done + 1

  IF (modz > @bailout)
    done = 0
  ENDIF

bailout:
  (done > 0)
default:
  title = "Slope Sierpinski Triangle II"
  center = (0.0, 0.0)
  magn = 1.1538
  maxiter = 149
  method = multipass
  periodicity = 0

  param bailout
    caption = "Bailout value"
    default = 127
    min = 1
  endparam

}
未命名.jpg
Slope Sierpinski Triangle II.gsp (17.53 KB)
pgd_Twofold2_Mandel {
  z = 1
  bool notdone = true
  int i = 0
  int j = 0
  bool odd = false
  complex z_values[@zmax]
  float b = 1/@bailout
loop:
  z = (sqr(z) - 1/3)/(#pixel * sqr(z) * z)
  IF (|z| > @bailout)
    notdone = false

  ENDIF
  z_values[i] = z
  IF (odd)
    IF (|z - z_values[j]| < b)
      notdone = false
      complex w = -1
      j = 0

      WHILE ((j < #maxit) )
        w = (sqr(w) - 1/3)/(#pixel * sqr(w) * w)

        j = j + 1
      ENDWHILE

    ENDIF
    j = j + 1
  ENDIF
  odd = !odd
  i = i + 1
bailout:
  notdone
default:
  title = "Twofold2 Mandelbrot"
  periodicity = 0
  maxiter = 1000
  method = onepass

  param zmax
    caption = "Max iters to record"
    default = 1000
  endparam
  param bailout
    caption = "Bailout"
    hint = "Escape radius (inverse is used for finite attractors)"
    default = 100000.0
    min = 0
  endparam
switch:
  type = "pgd_Twofold2_Julia"
  seed = #pixel
  bailout = bailout
}
这是一个分形的浓缩代码,通过UF验证,此代码与原长代码的该开关项,图形差别甚微(不知究竟差别在那,大家可帮我验证验证),因本人将原代码删掉太多,难免要走样。此分形代码中:z_values[@zmax]
是什么意思?这句搞懂后,分形易造。
59# 榕坚
对的,因为加了颜色后,没有小i了,现已更正。谢谢,既然如此,摆在这,看有没有不世出的高人弄出。
UF中的另一特效:
作色程序:
TangentCircles {
; Mark Townsend, 29 Apr 1999
;
; ****** NOTE *******
; Instead of using this coloring method use
; the Tangent Balls mode of the Paul Carlson's
; Orbit Traps method in pwc.ucl.
; *******************
;
; Paul W. Carlson's Tangent Circles oribit trap
; method.
;
init:
  int iter = 0
  float x = 0
  float y = 0
  float Xabs = 0
  float Yabs = 0
  float Dsgd0 = 0
  float Dsgd1 = 0
  float Dsgd2 = 0
  float Circle = 0
  float ZtoPsqd = 0
  float Rc = @r
  float Phi = #pi * 0.125
  float Rm = Rc / sin(Phi)
  float RcSqd = Rc^2
  float Py = Rm * sin(2 * Phi)
  float Px = Rm * cos(2 * Phi)
  bool Trapped = false
loop:
  iter = iter + 1
  x = real(#z)
  y = imag(#z)
  if abs((cabs(#z) - Rm)) < Rc && iter > @skip && !Trapped
    Xabs = abs(x)
    Yabs = abs(Y)
    Dsgd0 = Xabs^2 + (Yabs - Rm)^2
    Dsgd1 = (Xabs - Px)^2 + (Yabs - Py)^2
    Dsgd2 = (Xabs - Rm)^2 + Yabs^2
    if Dsgd0 < RcSqd
      Trapped = true
      ZtoPsqd= Dsgd0
      if y > 0
        Circle = 0
      else
        Circle = 4
      endif
    elseif Dsgd1 < RcSqd
      Trapped = true
      ZtoPsqd= Dsgd1
      if y >  0&& x > 0
        Circle = 1
      elseif y < 0 && x > 0
        Circle = 3
      elseif y < 0 && x < 0
        Circle = 5
      else
        Circle = 7
      endif
    elseif Dsgd2 < RcSqd
      trapped = true
      ZtoPsqd = Dsgd2
      if x > 0
        Circle = 2
      else
        Circle = 6
      endif
   endif
endif
final:
  if !trapped
    #solid = true
  else
    Circle = (Circle + @off) % 8
    float Ratio = sqrt(ZtoPsqd/Rcsqd)
    float ColorIndex = 29 * Ratio + Circle * 30
    #index = (ColorIndex + 1) % 256 /256
  endif
default:
  title = "Carlson Tangent Circles"
  param r
    caption = "Circle radius"
    default = 0.2
  endparam
  param skip
    caption = "Iters to skip"
    default = 1
    hint = "Iterations to skip."
  endparam
  param off
    caption = "Hue cycle"
    default = 0
    min = 0
    max = 7
    hint = "This rotates the coloring order of the balls."
  endparam
}
感觉到程序不是太难,从UF的效果来看,类似作过的圆陷阱,我正在用画板整,感觉到可能要失败。大家想想办法。
Fractal1.jpg
62# 榕坚
此句好象是调除M集肚内与众多圆陷阱外的颜色用的,我试了,此值若为true,则为黑,若为false,则为默认的天蓝色。我将
if !trapped
    #solid = true
  else
    Circle = (Circle + @off) % 8
    float Ratio = sqrt(ZtoPsqd/Rcsqd)
    float ColorIndex = 29 * Ratio + Circle * 30
    #index = (ColorIndex + 1) % 256 /256
中if后的!号去掉,并将#solid = true
  else
拿掉,变成这样:
if trapped

        Circle = (Circle + @off) % 8
    float Ratio = sqrt(ZtoPsqd/Rcsqd)
    float ColorIndex = 29 * Ratio + Circle * 30
    #index = (ColorIndex + 1) % 256 /256
在UF中试,结果影响不大。另外,将#solid改为任一变量,如a等等,不影响。
64# 榕坚
应该是这样理解的。我刚才乱整一通,整出了几个圈圈,有些相象。可能我的迭代有问题,好象是将着色程序中的x,y,也就是将M集的#z,可能是z0,替代x,y,让其与M集一同迭代。这我还没试。刚才乱整出的圈圈预言,这能用画板实现。
未命名.JPG
另外,从UF中看,那些圆圈被黑M集压住,应该是用dxy老师的M集外部q法用#index作色。
好象我已经做出来了,正在扫图:
未命名.JPG
扫了一个黑白的,白天再整一个彩色的。
返回列表