五角星链条陷阱20150312 {
init:
int iter = 0
float x = 0
float y = 0
float xB=0
float yB=0
float dAB=0
float dBC=0
float dAC=0
float Dsgd1 = 0
float ZtoPsqd = 0
float Rc = @r
float H=@h
float ID=0
bool Trapped = false
loop:
z1=#z*exp(-0.25*pi*1i)
x=real(z1)
y=imag(z1)
L1=0.5*sqrt(2)*x-0.5*sqrt(2)*y
L2=0.5*sqrt(2)*x+0.5*sqrt(2)*y
if L1<0&&L2>0
an3=0
elseif L1<0&&L2<0
an3=-pi/2
elseif L1>0&&L2<0
an3=-pi
elseif L1>0&&L2>0
an3=pi/2
endif
z1=z1*exp(1i*an3)
x = real(z1)
y = imag(z1)-@weitiao
int k=0
while (k<@nabs)
y=abs(y)-2*Rc
k = k+1
endwhile
y=abs(y)-Rc
z1=x+1i*y
z1=(z1-@xx-@yy*1i)*exp(-@an*pi/180*1i)
x = real(z1)
y = imag(z1)
m1=tan(0.2*pi)*x-y
m2=tan(0.4*pi)*x+y
m3=tan(0.4*pi)*x-y
m4=tan(0.2*pi)*x+y
if m1>0&&m4>0
ann=0
elseif m1<0&&m2>0
ann=-0.4*pi
elseif m2<0&&y>0
ann=-0.8*pi
elseif y<0&&m3<0
ann=0.8*pi
elseif m3>0&&m4<0
ann=0.4*pi
endif
z1=z1*exp(ann*1i)
x = real(z1)
y = imag(z1)
xB=0.309017*Rc
yB=0.224514*Rc
LOB=0.726543*x-y
LOB1=x+0.726543*y-xB-0.726543*yB
LOC=0.726543*x+y
LOC1=x-0.726543*y-xB-0.726543*yB
dAB=abs(yB*x-(xB-Rc)*y-yB*Rc)/sqrt(yB^2+(xB-Rc)^2)
dBC=abs(x-xB)
dAC=abs(yB*x+(xB-Rc)*y-yB*Rc)/sqrt(yB^2+(xB-Rc)^2)
if iter>@skip
if (@rangevar==0&&!Trapped) ||(@rangevar==1)
if LOB>0&&LOB1>0&&y>0&&dAB<H
Dsgd1=dAB
ID=iter
ZtoPsqd= Dsgd1
Trapped= true
elseif LOB>0&&LOC>0&&LOB1<0&&LOC1<0&&dBC<H
Dsgd1=dBC
ID=iter
ZtoPsqd= Dsgd1
Trapped= true
elseif LOC>0&&LOC1>0&&y<0&&dAC<H
Dsgd1=dAC
ID=iter
ZtoPsqd= Dsgd1
Trapped= true
endif
endif
endif
iter= iter + 1
final:
if !Trapped
#solid=true
else
ID = (@off+ID)%8
float Ratio = 1-ZtoPsqd/H
float ColorIndex = 29 * Ratio + ID * 30
#index = (ColorIndex +1) % 256 /256
endif
default:
title = "五角星链条陷阱20150312"
param r
caption = "Circle radius"
default = 1.0
endparam
param h
caption = "h"
default = 0.100
endparam
param nabs
caption = "链长参数"
default = 5
endparam
param weitiao
caption = "微调五角星链中心"
default = 12.00000
endparam
param an
caption = "五角星旋转角"
default =-18
endparam
param xx
caption = "五角星中心横标"
default =0.00000
endparam
param yy
caption = "五角星中心纵标"
default =0.0000
endparam
param rangevar
caption="range variable"
default=0
enum="先上后下" "后来居上"
endparam
param off
caption = "off"
default =1
endparam
param skip
caption = "skip"
default =0
endparam
}
|