返回列表 回复 发帖
未命名.jpg
未命名.jpg
Hilbert spline 2.gsp (45.55 KB)
本人调色始终差炎候,UF中的色彩真艳:
Fractal2.JPG
调一幅:
未命名.jpg
将原M集的数据粘到#13中,将M集的迭代终点坐标加载到原希氏数据中,只需花几分钟时长。扫得一图:
未命名.jpg
未命名.jpg
M集作陷阱的UF代码,精简,整理,编辑,几处代码动的手脚比较大,发现图形没什么两样:
juliatrap(BOTH) {
; By Samuel Monnier, 1999
init:
   count = 0
  float stdz = 0.0
  float logp = 1/log(2)
  float logb = log(log(1e20))
    float dz = 0.0
loop:
  trz = exp(flip(-pi/180*@rot))*(#z-@center)/@size
  x = 1/sqrt(@r)*real(trz)
  y = sqrt(@r)*imag(trz)
    trz = x + flip(y)
  zz = trz
  float i = 0
  iter = @niter


    start = zz
    zz = @seed


  while i < @niter
    i = i + 1
    zz = zz^2 + start
    if |zz| > 1e20
      iter = i
      i = @niter
    endif

  endwhile
  dz = real(iter + logp*logb - logp*log(log(cabs(zz))))
    if dz>stdz
      stdz = dz


    endif


final:
  #index = .1*stdz
default:
  title = "Julia Trap"
  helpfile = "sam-help/juliatrap.htm"
  param seed
    caption = "Seed (for 'custom')"
    default = (0,0)
  endparam
  param center
    caption = "Center"
    default = (1,1)
  endparam
  param rot
    caption = "Rotation"
    default = -30.0
  endparam
  param size
    caption = "Size"
    default = 0.386750
  endparam
  param r
    caption = "Ratio Width/Heigh"
    default = 1.0
  endparam
  param @niter
    caption = "Julia Iterations"
    default = 100
  endparam
  param freq
    caption = "Trap Frequency"
    default = 0.0
  endparam
}
Fractal2.JPG
红色部分是我动过手脚比较大的部分,原代码是:
if first
      stdz = dz
      first = false
    elseif dz > stdz
      stdz = dz
    endif
这段代码如读天书,所以改成红色部分后,效果一样。红色部分是什么意思?
没考虑红色部分,用画板则得效果如下:
未命名.JPG
等势圈遮住了M集部分,图看起来不舒服。在UF中拿掉这部分代码,则与GSP一致!这段代码是什么意思?如何处理?dz中的iter,其实就是充当陷阱M集的et。
原代码内含开关项,鄙人将不是帖图的开关项赐除,其余几乎没动过,结果常老师尝试,好似成功了。UF原装代码如下:
hilbert-curve {
; Kerry Mitchell 15jul2001
;
; Draws a Hilbert curve in the #z plane and colors by the
; orbit's relationship to the curve.  Only uses the last
; iterate.  Allows you to change the locations of the 4
; sub-square centers, and the point where the curve enters
; and exits the block of 4 squares.
;
init:
  float x=0.0
  float y=0.0
  float r=0.0
  float rmin=1e20
  float u=0.0
  float v=0.0
  float msb=0.0
  t=(0,0)
  int iter=0
  int nlast=0
  int n=0
  int fac3=0
  int fac4=0
  int power4=0
  zh=(0,0)
  zh0=(0,0)
;
; set up endpoints for the lines
;
  float h=@fourcorners
  float ooh=1/h
  float ooomh=1/(1-h)
  float hoomh=h/(1-h)
  z0a=@enterexit*h
  z0b=flip(@enterexit*h)
  x=real(@centerll)*h
  y=imag(@centerll)*h
  z1=x+flip(y)
  x=real(@centerul)*h
  y=imag(@centerul)*(1-h)+h
  z2=x+flip(y)
  x=real(@centerur)*(1-h)+h
  y=imag(@centerur)*(1-h)+h
  z3=x+flip(y)
  x=real(@centerlr)*(1-h)+h
  y=imag(@centerlr)*h
  z4=x+flip(y)
  z5=1+flip(@enterexit*h)
loop:
final:
  iter=0
  zh0=#z*0.25+(0.5,0.5)
  zh=zh0
  while(iter<@niter)
    iter=iter+1
    x=real(zh)
    y=imag(zh)
;
; lower left sub-square:  shrink, flip horizontally, rotate by -90 degrees
;
    if((x<h)&&(y<h))
      nlast=3
      u=ooh*y
      v=ooh*x
;
; upper left sub-square:  just shrink
;
    elseif((x<h)&&(y>=h))
      nlast=2
      u=ooh*x
      v=ooomh*y-hoomh
;
; upper right sub-square:  shrink & flip horizontally
;
    elseif((x>=h)&&(y>=h))
      nlast=1
      u=ooomh-ooomh*x
      v=ooomh*y-hoomh
;
; lower right sub-square:  shrink, rotate by 90 degrees
;
    elseif((x>=h)&&(y<h))
      nlast=4
      u=ooh*y
      v=ooomh-ooomh*x
    else
      nlast=-1
      u=x
      v=y
    endif
    zh=u+flip(v)
    msb=(msb+nlast-1)/4
    n=n*4+nlast-1
  endwhile
  if(n<0)
    #solid=true
  else
    if(@colorby==1)          ; least significant bit
      #index=n/(4^@niter)
    elseif(@colorby==2)      ; most significat bit
      #index=msb
    elseif(@colorby==3)      ; distance from initial z
      #index=cabs(zh-zh0)
    elseif(@colorby==4)      ; angle from initial z
      r=atan2(zh-zh0)/#pi
      if(r<0.0)
        r=r+2
      endif
      #index=r/2
    else                     ; distance to curve
;
; determine how to start line 0-1
;
    z0=z0a
    iter=0
    fac3=2
    fac4=1
    power4=4
    while(iter<@niter)
      iter=iter+1
      if(iter%2==1)
        if(n%power4==fac3)
          z0=z0b
        endif
      else
        if(n%power4==fac3)
          z0=z0a
        endif
      endif
      power4=4*power4
      fac4=4*fac4
      fac3=fac3+2*fac4
    endwhile
;
; line from enter to lower left sub-square
;
    t=(zh-z0)/(z1-z0)
    x=real(t)
    y=imag(t)
    if(x<0.0)
      r=sqr(x)+sqr(y)
    elseif(x>1.0)
      r=sqr(x-1.0)+sqr(y)
    else
      r=sqr(y)
    endif
    r=sqrt(r)*cabs(z1-z0)
    if(r<rmin)
      rmin=r
    endif
;
; line from lower left to upper left sub-squares
;
    t=(zh-z1)/(z2-z1)
    x=real(t)
    y=imag(t)
    if(x<0.0)
      r=sqr(x)+sqr(y)
    elseif(x>1.0)
      r=sqr(x-1.0)+sqr(y)
    else
      r=sqr(y)
    endif
    r=sqrt(r)*cabs(z2-z1)
    if(r<rmin)
      rmin=r
    endif
;
; line from upper left to upper right sub-squares
;
    t=(zh-z2)/(z3-z2)
    x=real(t)
    y=imag(t)
    if(x<0.0)
      r=sqr(x)+sqr(y)
    elseif(x>1.0)
      r=sqr(x-1.0)+sqr(y)
    else
      r=sqr(y)
    endif
    r=sqrt(r)*cabs(z3-z2)
    if(r<rmin)
      rmin=r
    endif
;
; line from upper right to lower right sub-squares
;
    t=(zh-z3)/(z4-z3)
    x=real(t)
    y=imag(t)
    if(x<0.0)
      r=sqr(x)+sqr(y)
    elseif(x>1.0)
      r=sqr(x-1.0)+sqr(y)
    else
      r=sqr(y)
    endif
    r=sqrt(r)*cabs(z4-z3)
    if(r<rmin)
      rmin=r
    endif
;
; line from lower right sub-square to exit
;
    t=(zh-z4)/(z5-z4)
    x=real(t)
    y=imag(t)
    if(x<0.0)
      r=sqr(x)+sqr(y)
    elseif(x>1.0)
      r=sqr(x-1.0)+sqr(y)
    else
      r=sqr(y)
    endif
    r=sqrt(r)*cabs(z5-z4)
    if(r<rmin)
      rmin=r
    endif
;
      #index=rmin
    endif
  endif
default:
  title="Hilbert curve"
  param centerll
    caption="lower left center"
    default=(0.5,0.5)
    hint="Center of the lower left sub-square. Make both coordinates \
    between 0 & 1; use (0.5,0.5) for standard Hilbert curve."
  endparam
  param centerul
    caption="upper left center"
    default=(0.5,0.5)
    hint="Center of the upper left sub-square. Make both coordinates \
    between 0 & 1; use (0.5,0.5) for standard Hilbert curve."
  endparam
  param centerur
    caption="upper right center"
    default=(0.5,0.5)
    hint="Center of the upper right sub-square. Make both coordinates \
    between 0 & 1; use (0.5,0.5) for standard Hilbert curve."
  endparam
  param centerlr
    caption="lower right center"
    default=(0.5,0.5)
    hint="Center of the lower right sub-square. Make both coordinates \
    between 0 & 1; use (0.5,0.5) for standard Hilbert curve."
  endparam
  param enterexit
    caption="enter/exit"
    default=0.5
    min=0.0
    max=1.0
    hint="Where the curve enters and exits the block of 4 sub-squares. \
      Between 0 & 1; use 0.5 for standard Hilbert curve."
  endparam
  param fourcorners
    caption="4 corners"
    default=0.5
    hint="Where the 4 corners meet.  Between 0 & 1; use 0.5 for standard \
      Hilbert curve."
  endparam
  param niter
    caption="iterations"
    default=0
    min=0
  endparam
  param colorby
    caption="color by"
    default=0
    enum="distance" "last = lsb" "last = msb" "distance from z" "angle from z"
  endparam
}
Fractal2.png
另外一个闭合回路的希氏曲线,我除了赐除开关项,还删除了一些代码,所以与UF中的希氏曲线相比,少了一些效果。里面也有几个开关项。现附上原装代码:
HilbertCurve(BOTH) {
; By Samuel Monnier, 2.9.00
init:
  z = 0
  int i = 0
  int ttype = 0
  float d = -1e20
loop:
  
final:
  
  z = #z/2
  z = abs(z) - (.5,.5)
  while i < @niter
    i = i + 1
    if ttype == 0
      if real(z) < 0 && imag(z) < 0
        z = 2*z + (.5,.5)
        z = -conj(z)
      elseif real(z) > 0 && imag(z) < 0
        z = 2*z + (-.5,.5)
        z = 1i*z
      elseif real(z) > 0 && imag(z) > 0
        z = 2*z + (-.5,-.5)
        z = 1i*conj(z)
      elseif real(z) < 0 && imag(z) > 0
        z = 2*z + (.5,-.5)
        ttype = 1
      endif
    else
      if real(z) < 0 && imag(z) < 0
        z = 2*z + (.5,.5)
        z = 1i*z
        ttype = 0
      elseif real(z) > 0 && imag(z) < 0
        z = 2*z + (-.5,.5)
        z = -1i*conj(z)
        ttype = 0
      elseif real(z) > 0 && imag(z) > 0
        z = 2*z + (-.5,-.5)
        ttype = 0
      elseif real(z) < 0 && imag(z) > 0
        z = 2*z + (.5,-.5)
        z = -conj(z)
        ttype = 0
      endif
    endif  
  endwhile
  
  if @style == 0
    z = z + (1,1)
    if ttype == 0
      if abs(real(z))-1 > d
        d = abs(real(z))-1
      endif
     if abs(imag(z))-1 > d
        d = abs(imag(z))-1
      endif
    else
      d = imag(z)-1
    endif
  elseif @style == 1 || @style == 2
    if ttype == 0
      d = cabs(z+(.5,.5))-.5
    else
      if @style == 1
        d = imag(z)
      else
        d = imag(z) - (real(z)^2-.25)^2*3
      endif
    endif
  elseif @style == 3
   
    if ttype == 0
      z = z + (.5,.5)
      d = abs(real(z)) + abs(imag(z)) - .5
    else
      ;d = imag(z)-.5
      d = abs(real(z)) - imag(z) - .5
    endif
  endif
   
  #index = abs(d)^@power
  
default:
  title = "Hilbert Curve"
  helpfile = "sam-help/hilbert.htm"
  
  param style
    caption = "Style"
    default = 0
    enum = "Square" "Round I" "Round II" "Diagonal"
  endparam  
  
  param power
    caption = "Thickness"
    default = .1
  endparam
  
  param niter
    caption = "Number of Iterations"
    default = 4
  endparam
}
附上第一个开关项的图:
Fractal2.png
返回列表