将前面的KochCurve曲线代码,删除了一段没用的代码,再浓缩成下面的代码:
KochCurve {
init:
z = #pixel
x = real(z)
y = imag(z)
sq3 = sqrt(3)
bail = false
bail2 =false
i = 1
loop:
i = i + 1
if i == 2
arg = atan2(z)
if (-y + 1/sq3 > 0) && (sq3*x + y + 2/sq3 > 0) \
&& (sq3*x - y - 2/sq3 < 0)
bail = true
endif
if (arg > 5/6*pi) || (arg < -pi/2)
z = z*exp(1i*4/3*pi)
endif
if (arg < pi/6) && (arg > -pi/2)
z = z*exp(1i*2/3*pi)
endif
z = z - 1i*1/sq3
elseif i > 2
z = 3*z
x = real(z)
y = imag(z)
if (y > 0) && (sq3*x - y + sq3 > 0) \
&& (sq3*x + y - sq3 < 0)
bail2 = true
endif
z = z/3
x = real(z)
if x < -1/3
z = 3*z + 2
elseif x > 1/3
z = 3*z - 2
else
if x < 0
z = z + 1/3
z = z*exp(-1i*pi/3)
z = 3*z - 1
elseif x> 0
z = z - 1/3
z = z*exp(1i*pi/3)
z = 3*z + 1
endif
endif
endif
bailout:
bail == false && bail2 == false
default:
title = "Koch Curve1"
helpfile = "sam-help/kochcurves.htm"
helptopic = "kcurve"
magn = 1.5
center = (0.0002,0)
maxiter = 50
}
作了几次,每次都不一样,查起来费劲,每干一次,扫出的图均不一样,怪。不过,倒是取得了进展,扫出的图有些地方可看到局部的科赫曲线影子。不知是不是我解读上面的代码,有误。
|