返回列表 回复 发帖
1.jpg
加点变换:
2.jpg
1.jpg
勾股树扫描(代数版本)六角星陷阱扫描20150305.gsp (33.47 KB)
数学变换太神奇了,由前面的六角星陷阱,再变换,得六个六个星陷阱。得八个八角星陷阱,也不成问题。如果照古时算法,算法复杂,怕画板已经早就停课了。
2.jpg
六角星陷阱旋转变换成6个6个星陷阱20150303.gsp (23.74 KB)
1.jpg
加载牛集看看:
2.jpg
再用上楼陷阱,加载圆科赫:
3.jpg
六角星陷阱的UF代码:
六角星陷阱20150307 {
init:
  int iter = 0
  float Circle=0
  float x = 0
  float y = 0
  float Dsgd1 = 0
  float ZtoPsqd = 0
  float Rc = @r
  float H=@h
float R=2*Rc
  float ID=0
  bool Trapped = false
loop:
  z0=#z*exp(-1i*@An*pi/180)
  x = real(z0)
  y = imag(z0)
  K1=sqrt(3)*x-3*y
  K2=sqrt(3)*x+3*y
if K1<0&&x>0
  k=-pi/3
  elseif K2>0&&x<0
  k=-2*pi/3
  elseif k2<0&&k1<0
  k=-pi
  elseif k1>0&&x<0
  k=2*pi/3
  elseif x>0&&k2<0
  k=pi/3
  elseif K1>0&&k2>0
  k=0
endif
z1=z0*exp(1i*k)-2*R
x=real(z1)
y = imag(z1)
J1=-y
J2=sqrt(3)*x+y
J3=sqrt(3)*x-y
if J1<0&&J2>0
m=0
elseif J2<0&&J3<0
m=-2*pi/3
elseif J1>0&&J3>0
m=2*pi/3
endif
z2=z1*exp(1i*m)
x=real(z2)
y=imag(z2)
L1=-y
L2=sqrt(3)*x+y
if L1<0&&L2>0
Dsgd1=abs(0.5*x+0.5*sqrt(3)*y-Rc)
endif
if iter>@skip
  if (@rangevar==0&&!Trapped) ||(@rangevar==1)
    if Dsgd1 <H
     ID=iter
     ZtoPsqd= Dsgd1
     Trapped= true
    endif
   endif
  endif
iter= iter + 1
final:
  if !Trapped
    #solid=true
  else
    Circle = (@off+ID)%8
    float Ratio = 1-ZtoPsqd/H
    float ColorIndex = 29 * Ratio + Circle * 30
    #index = (ColorIndex +1) % 256 /256
  endif
default:
  title = "等边三角形陷阱变换出的六角星陷阱"
  param r
    caption = "Circle radius"
    default = 0.1
  endparam
    param h
    caption = "h"
    default = 0.05
  endparam

param rangevar
    caption="range variable"
    default=0
    enum="先上后下" "后来居上"
  endparam
param off
    caption = "off"
    default =1
  endparam
param An
    caption = "六角星整体转角"
    default =0
  endparam
param skip
    caption = "skip"
    default =0
  endparam
}
柳烟注:这个代码用的是等边三角形陷阱经旋转所得六角星代码,没用前面GSP中所用的旋转加轴对称迅速得到六角星代码,因为一加轴对称,在UF中的六角星有的正常,有的缺失,不知何故。GSP效果似要好于UF。
Fractal2.png
UF中六个六个星陷阱下的M集:
New.jpg
327# 柳烟
漂亮!
用旋转一边的方法作多边星形陷阱
图片.jpg
五&六边星形陷阱工具.gsp (38.59 KB)
UF中的六个六角星代码:
六个六角星陷阱20150307 {
init:
  int iter = 0
  float Circle=0
  float x = 0
  float y = 0
  float Dsgd1 = 0
  float ZtoPsqd = 0
  float Rc = @r
  float H=@h
float R=2*Rc
  float ID=0
  bool Trapped = false
loop:
   x=real(#z)
   y=imag(#z)
   K11=sqrt(3)*x-3*y
  K21=sqrt(3)*x+3*y
if K11<0&&x>0
  t=-pi/3
  elseif K21>0&&x<0
  t=-2*pi/3
  elseif k21<0&&k11<0
  t=-pi
  elseif k11>0&&x<0
  t=2*pi/3
  elseif x>0&&k21<0
  t=pi/3
  elseif K11>0&&k21>0
  t=0
endif
   z00=#z*exp(1i*t)-@pp
  z0=z00*exp(-1i*@An*pi/180)
  x = real(z0)
  y = imag(z0)
  K1=sqrt(3)*x-3*y
  K2=sqrt(3)*x+3*y
if K1<0&&x>0
  k=-pi/3
  elseif K2>0&&x<0
  k=-2*pi/3
  elseif k2<0&&k1<0
  k=-pi
  elseif k1>0&&x<0
  k=2*pi/3
  elseif x>0&&k2<0
  k=pi/3
  elseif K1>0&&k2>0
  k=0
endif
z1=z0*exp(1i*k)-2*R
x=real(z1)
y = imag(z1)
J1=-y
J2=sqrt(3)*x+y
J3=sqrt(3)*x-y
if J1<0&&J2>0
m=0
elseif J2<0&&J3<0
m=-2*pi/3
elseif J1>0&&J3>0
m=2*pi/3
endif
z2=z1*exp(1i*m)
x=real(z2)
y=imag(z2)
L1=-y
L2=sqrt(3)*x+y
if L1<0&&L2>0
Dsgd1=abs(0.5*x+0.5*sqrt(3)*y-Rc)
endif
if iter>@skip
  if (@rangevar==0&&!Trapped) ||(@rangevar==1)
    if Dsgd1 <H
     ID=iter
     ZtoPsqd= Dsgd1
     Trapped= true
    endif
   endif
  endif
iter= iter + 1
final:
  if !Trapped
    #solid=true
  else
    Circle = (@off+ID)%8
    float Ratio = 1-ZtoPsqd/H
    float ColorIndex = 29 * Ratio + Circle * 30
    #index = (ColorIndex +1) % 256 /256
  endif
default:
  title = "六角星陷阱变换出的六个六角星陷阱"
  param r
    caption = "Circle radius"
    default = 0.1
  endparam
    param h
    caption = "h"
    default = 0.05
  endparam

param rangevar
    caption="range variable"
    default=0
    enum="先上后下" "后来居上"
  endparam
param off
    caption = "off"
    default =1
  endparam
  param pp
    caption = "系数调整"
    default =1.00000
  endparam
param An
    caption = "六角星整体转角"
    default =0
  endparam
param skip
    caption = "skip"
    default =0
  endparam
}
Fractal2.png
Fractal2.png
Fractal2.png
也扫一个五角星:
3.jpg
五角星陷阱设置优化20150309.gsp (24.06 KB)
返回列表