上面弦图的UF陷阱代码:
弦图陷阱代码 {
;20140617柳烟作
init:
int iter = 0
float x = 0
float y = 0
float xA=0
float yA=0
float xB=0
float yB=0
float xC=0
float yC=0
float xD=0
float yD=0
float lAB=0
float lBC=0
float lCD=0
float lDA=0
float x1=0
float y1=0
float x2=0
float y2=0
float x3=0
float y3=0
float x4=0
float y4=0
float l1=0
float l2=0
float l3=0
float l4=0
float Dsgd1 = 0
float Dsgd2 = 0
float Dsgd3 = 0
float Dsgd4 = 0
float ZtoPsqd = 0
float Rc = @r
float H = sqrt(2)*Rc
float phi = @angle*pi/180
float CI=0
float ID=0
bool Trapped = false
loop:
iter= iter + 1
x = real(#z)
y = imag(#z)
xA= Rc*cos(phi)+ @o1x
yA= Rc*sin(phi)+@o1y
xB=Rc*cos(phi+0.5*pi)+@o1x
yB=Rc*sin(phi+0.5*pi)+@o1y
xC=Rc*cos(phi+pi)+@o1x
yC=Rc*sin(phi+pi)+@o1y
xD=Rc*cos(phi+1.5*pi)+@o1x
yD=Rc*sin(phi+1.5*pi)+@o1y
lAB=(yA-yB)*x-(xA-xB)*y+(xA*yB-yA*xB)
lBC=(yB-yC)*x-(xB-xC)*y+(xB*yC-yB*xC)
lCD=(yC-yD)*x-(xC-xD)*y+(xC*yD-yC*xD)
lDA=(yD-yA)*x-(xD-xA)*y+(xD*yA-yD*xA)
x1=(xA+@bb*xB)/(1+@bb)
y1=(yA+@bb*yB)/(1+@bb)
x2=(xB+@bb*xC)/(1+@bb)
y2=(yB+@bb*yC)/(1+@bb)
x3=(xC+@bb*xD)/(1+@bb)
y3=(yC+@bb*yD)/(1+@bb)
x4=(xD+@bb*xA)/(1+@bb)
y4=(yD+@bb*yA)/(1+@bb)
l1=(y1-yC)*x-( x1-xC)*y+(x1*yC-y1*xC)
l2=(y2-yD)*x-( x2-xD)*y+(x2*yD-y2*xD)
l3=(y3-yA)*x-( x3-xA)*y+(x3*yA-y3*xA)
l4=(y4-yB)*x-( x4-xB)*y+(x4*yB-y4*xB)
Dsgd1=sqrt((x-xB)^2+(y-yB)^2)
Dsgd2=sqrt((x-xC)^2+(y-yC)^2)
Dsgd3=sqrt((x-xD)^2+(y-yD)^2)
Dsgd4=sqrt((x-xA)^2+(y-yA)^2)
if iter>@skip
if (@rangevar==0&&!Trapped) ||(@rangevar==1)
if (lAB>0&&l3>0)&&l4<0
ID=iter
ZtoPsqd= Dsgd1
Trapped= true
CI=1
elseif (lBC>0&&l4>0)&&l1<0
ID=iter
ZtoPsqd= Dsgd2
Trapped= true
CI=2
elseif (lCD>0&&l1>0)&&l2<0
ID=iter
ZtoPsqd= Dsgd3
Trapped= true
CI=3
elseif (lDA>0&&l2>0)&&l3<0
ID=iter
ZtoPsqd= Dsgd4
Trapped= true
CI=4
endif
endif
endif
final:
if !Trapped
#solid=true
else
CI = (@off+ID)%7
float Ratio = ZtoPsqd/H
float ColorIndex = 29 * Ratio + CI* 45
#index = (ColorIndex +60) % 256 /256
endif
default:
title = "弦图陷阱UF"
param r
caption = "Rc"
default = 0.5
endparam
param o1x
caption = "o1x"
default =0.0000
endparam
param o1y
caption = "o1y"
default =0.0000
endparam
param rangevar
caption="range variable"
default=0
enum="先上后下" "后来居上"
endparam
param off
caption = "off"
default =1
endparam
param angle
caption = "angle"
default =0
endparam
param bb
caption = "bb"
default =1.5
endparam
param skip
caption = "skip"
default =0
endparam
}
|