六角星陷阱的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。
|