陷阱变换单圆环变8切环 {
init:
int iter = 0
float Circle=0
float x = 0
float s = 0
float L1 = 0
float L2 = 0
float L3 = 0
float L4 = 0
float y = 0
float Dsgd1 = 0
float ZtoPsqd = 0
float Rc = @r
float H=@h
float ID=0
bool Trapped = false
loop:
x = real(#z)
y = imag(#z)
l1=tan(pi/8)*x-y
L2=tan(pi/8)*x+y
L3=tan(3*pi/8)*x-y
L4=tan(3*pi/8)*x+y
if L1<0&&L3>0
s=-pi/4
elseif L3<0&&L4>0
s=-pi/2
elseif L4<0&&L2>0
s=-3*pi/4
elseif L2<0&&L1<0
s=pi
elseif L1>0&&L3<0
s=3*pi/4
elseif L3>0&&L4<0
s=pi/2
elseif L4>0&&L2<0
s=pi/4
elseif L1>0&&L2>0
s=0
endif
ZZ=#z*exp(1i*s)
x=real(ZZ)
y=imag(ZZ)
Dsgd1 =abs(sqrt((x-(Rc+H)/sin(pi/8))^2+y^2)-Rc)
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)%7
float Ratio = 1-ZtoPsqd/H
float ColorIndex = 29 * Ratio + Circle * 30
#index = (ColorIndex +1) % 256 /256
endif
default:
title = "陷阱变换单圆环变8环"
param r
caption = "Circle radius"
default = 0.05
endparam
param h
caption = "h"
default = 0.02
endparam
param rangevar
caption="range variable"
default=0
enum="先上后下" "后来居上"
endparam
param off
caption = "off"
default =1
endparam
param skip
caption = "skip"
default =0
endparam
}
代码中,r=0,H为非零正数,即可得八切球陷阱。
|