int n_live ; how many orbits can bail out until we're done?
if @giveup=="all done"
n_live = n_orbits
else
n_live = 1
endif
int step=0 ; which attractor are we checking ? (with @stripes)
loop:
int ix = 0 ; count through the orbits
repeat
int found=-1
if continue[ix] ; orbit still live ?
z = orbit[ix]
if (@stripes)
; stripes: check only one attractor
dist = z-attract[step]
if |dist| < @delta
found=step
endif
else
; no stripes: check all attractors
int j=0 ; loop through the attractors
repeat
dist = z-attract[j]
if |dist| < @delta
found = j
endif
j=j+1
until j>=n_attract || found>=0
endif ; stripes
if (found>=0)
continue[ix] = false
n_live = n_live - 1
elseif (!@stripes || step==n_attract-1)
; here we step z (this is the core of the formula)
zprev = z
z = (3*z^4 - 4*@b*z^3 + fac2*z^2 + fac0) / ( 4*z^3 - 6*@b*z^2 + 2*fac2*z + 2*@b)
orbit[ix] = z
endif ; found
endif ; continue
ix = ix + 1
until ix >= n_orbits || n_live <= 0
if @stripes
step = step+1
if step >= n_attract
step = 0
endif
endif
; if we're bailing out, and zmode is != z, adjust the final z (for coloring algorithm)
if @zmode != "z"
if n_live <= 0
if @zmode=="distance"
z = dist
elseif @zmode=="step"
z = z-zprev
endif ; zmode
endif ; found
endif ; zmode
bailout:
; -- this isn't the bailout but the continuing condition
; false = bail; true = continue
n_live > 0
default:
title = "Newton-Mandel(a), degree-4 polynomial" ; v1.0
periodicity = 0 ; turn off periodicity checking by default as it interferes with 'stripes'
heading
caption = "Bailout"
endheading
float param delta
caption="Bailout delta"
hint="How close can z get to a fixed point? \
Actually, this is the square of the distance. \
Smaller values mean more iterations."
default=1e-10
min=0
endparam
param giveup
caption = "Stop when"
enum = "all done" "any done" "one" "other" "custom orbit start"
default = 0
endparam
complex param z_init
caption = "orbit start"
enabled = @giveup == "custom orbit start"
default = 0
endparam
heading
caption = "Coloring"
endheading
bool param stripes
caption="Staggered iteration"
hint="Checking this box means you can use one of the striped coloring methods. Use 4 stripes."
default=false
endparam
bool param reorder
; enabled = @stripes
default = false
caption = "Reorder attractors"
hint = "Exchange the attractors 1 and 2 (of 0..3). \
Matters if you use staggered iteration, or in the rare case when two attractors coincide."
endparam
param zmode
caption = "final z"
enum = "z" "distance" "step"
default = 1 ; "distance"
endparam
switch:
type = "N_Poly4_J"
pchoice = pchoice
a = #pixel
b = b
delta = delta
reorder = reorder
stripes = stripes
zmode = zmode
}
再增添榕坚老师转来代码之前一段外文:
N_Poly4_Ma {
; newton's method applied to P(z) = (z + 1) * (z - 1) * (z - b + a) * (z - b - a)
; Parameter plane (M-set) for all 'a' and a specific 'b'
; F(z) = z - P(z)/P'(z)
; F(z) = (3*z^4 - 4*b*z^3 + (b^2-a^2-1)*z^2 + (b^2-a^2)) / ( 4*z^3 - 6*b*z^2 + 2*(b^2-a^2-1)*z + 2*b)
; Attractors: the 4 zeros of P(z): 1,-1, b+a, b-a
; Critical points: the 4 zeros, as well as
; b/2 +/- sqrt(3)*sqrt(b^2 + 2*a^2 + 2)/6
; For b=0, this reverts to the 'Newt_fang_xxx' formulas from pwc_convert.ufm