Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
51
Task/Dragon-curve/Gnuplot/dragon-curve-1.gnuplot
Normal file
51
Task/Dragon-curve/Gnuplot/dragon-curve-1.gnuplot
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# Return the position of the highest 1-bit in n.
|
||||
# The least significant bit is position 0.
|
||||
# For example n=13 is binary "1101" and the high bit is pos=3.
|
||||
# If n==0 then the return is 0.
|
||||
# Arranging the test as n>=2 avoids infinite recursion if n==NaN (any
|
||||
# comparison involving NaN is always false).
|
||||
#
|
||||
high_bit_pos(n) = (n>=2 ? 1+high_bit_pos(int(n/2)) : 0)
|
||||
|
||||
# Return 0 or 1 for the bit at position "pos" in n.
|
||||
# pos==0 is the least significant bit.
|
||||
#
|
||||
bit(n,pos) = int(n / 2**pos) & 1
|
||||
|
||||
# dragon(n) returns a complex number which is the position of the
|
||||
# dragon curve at integer point "n". n=0 is the first point and is at
|
||||
# the origin {0,0}. Then n=1 is at {1,0} which is x=1,y=0, etc. If n
|
||||
# is not an integer then the point returned is for int(n).
|
||||
#
|
||||
# The calculation goes by bits of n from high to low. Gnuplot doesn't
|
||||
# have iteration in functions, but can go recursively from
|
||||
# pos=high_bit_pos(n) down to pos=0, inclusive.
|
||||
#
|
||||
# mul() rotates by +90 degrees (complex "i") at bit transitions 0->1
|
||||
# or 1->0. add() is a vector (i+1)**pos for each 1-bit, but turned by
|
||||
# factor "i" when in a "reversed" section of curve, which is when the
|
||||
# bit above is also a 1-bit.
|
||||
#
|
||||
dragon(n) = dragon_by_bits(n, high_bit_pos(n))
|
||||
dragon_by_bits(n,pos) \
|
||||
= (pos>=0 ? add(n,pos) + mul(n,pos)*dragon_by_bits(n,pos-1) : 0)
|
||||
|
||||
add(n,pos) = (bit(n,pos) ? (bit(n,pos+1) ? {0,1} * {1,1}**pos \
|
||||
: {1,1}**pos) \
|
||||
: 0)
|
||||
mul(n,pos) = (bit(n,pos) == bit(n,pos+1) ? 1 : {0,1})
|
||||
|
||||
# Plot the dragon curve from 0 to "length" with line segments.
|
||||
# "trange" and "samples" are set so the parameter t runs through
|
||||
# integers t=0 to t=length inclusive.
|
||||
#
|
||||
# Any trange works, it doesn't have to start at 0. But must have
|
||||
# enough "samples" that all integers t in the range are visited,
|
||||
# otherwise vertices in the curve would be missed.
|
||||
#
|
||||
length=256
|
||||
set trange [0:length]
|
||||
set samples length+1
|
||||
set parametric
|
||||
set key off
|
||||
plot real(dragon(t)),imag(dragon(t)) with lines
|
||||
20
Task/Dragon-curve/Gnuplot/dragon-curve-2.gnuplot
Normal file
20
Task/Dragon-curve/Gnuplot/dragon-curve-2.gnuplot
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
## plotdcf.gp 1/11/17 aev
|
||||
## Plotting a Dragon curve fractal to the png-file.
|
||||
## Note: assign variables: ord (order), clr (color), filename and ttl (before using load command).
|
||||
## ord (order) # a.k.a. level - defines size of fractal (also number of mini-curves).
|
||||
reset
|
||||
set style arrow 1 nohead linewidth 1 lc rgb @clr
|
||||
set term png size 1024,1024
|
||||
ofn=filename.ord."gp.png" # Output file name
|
||||
set output ofn
|
||||
ttl="Dragon curve fractal: order ".ord
|
||||
set title ttl font "Arial:Bold,12"
|
||||
unset border; unset xtics; unset ytics; unset key;
|
||||
set xrange [0:1.0]; set yrange [0:1.0];
|
||||
dragon(n, x, y, dx, dy) = n >= ord ? \
|
||||
sprintf("set arrow from %f,%f to %f,%f as 1;", x, y, x + dx, y + dy) : \
|
||||
dragon(n + 1, x, y, (dx - dy) / 2, (dy + dx) / 2) . \
|
||||
dragon(n + 1, x + dx, y + dy, - (dx + dy) / 2, (dx - dy) / 2);
|
||||
eval(dragon(0, 0.2, 0.4, 0.7, 0.0))
|
||||
plot -100
|
||||
set output
|
||||
20
Task/Dragon-curve/Gnuplot/dragon-curve-3.gnuplot
Normal file
20
Task/Dragon-curve/Gnuplot/dragon-curve-3.gnuplot
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
## pDCF.gp 1/11/17 aev
|
||||
## Plotting 3 Dragon curve fractals.
|
||||
## Note: assign variables: ord (order), clr (color), filename and ttl (before using load command).
|
||||
## ord (order) # a.k.a. level - defines size of fractal (also number of dots).
|
||||
#cd 'C:\gnupData'
|
||||
|
||||
##DCF11
|
||||
ord=11; clr = '"red"';
|
||||
filename = "DCF"; ttl = "Dragon curve fractal, order ".ord;
|
||||
load "plotdcf.gp"
|
||||
|
||||
##DCF13
|
||||
ord=13; clr = '"brown"';
|
||||
filename = "DCF"; ttl = "Dragon curve fractal, order ".ord;
|
||||
load "plotdcf.gp"
|
||||
|
||||
##DCF15
|
||||
ord=15; clr = '"navy"';
|
||||
filename = "DCF"; ttl = "Dragon curve fractal, order ".ord;
|
||||
load "plotdcf.gp"
|
||||
Loading…
Add table
Add a link
Reference in a new issue