gnuplot script:
square(x,y) = abs(x + y) + abs(x - y) - 3
S0(x,y) = abs(x + y) + abs(x - y) - 1
f(x) = 3*abs(x) - 3
S1(x,y) = S0(3*x, f(y)) * S0(f(x), 3*y) * S0(f(x), f(y))
S2(x,y) = S1(3*x, f(y)) * S1(f(x), 3*y) * S1(f(x), f(y))
S3(x,y) = S2(3*x, f(y)) * S2(f(x), 3*y) * S2(f(x), f(y))
S4(x,y) = S3(3*x, f(y)) * S3(f(x), 3*y) * S3(f(x), f(y))
fun(x,y) = square(x,y)>0 || S0(x,y)<0 || S1(x,y)<0 || \
S2(x,y)<0 || S3(x,y)<0 || S4(x,y)<0 ? 0:1
set xrange [-1.5:1.5]
set yrange [-1.5:1.5]
set pm3d map
unset colorbox
set palette model RGB defined (0 'white', 1 'red')
set size ratio -1
set samples 640
set isosamples 640
unset key
unset xtics
unset ytics
unset border
splot fun(x,y)
Graph example:
Click here to download the example file (sierpinski_carpet.grf).
No comments:
Post a Comment