Sunday, June 29, 2014

Sinusoidal Strings - made from a ring of circles

Sinusoidal Strings of Pebbles (r=0.1, n=32)

(r=0.15, n=42)

(r=0.4, n=60)

A ring of circles can be expressed as follows:
x = cos(t-mod(t,s)) + r*cos(n*mod(t,s))
y = sin(t-mod(t,s)) + r*sin(n*mod(t,s))
r=0.1, n=32, s=2*pi/n, t=0...2*pi.

Note that mod(t,s) = t - s*floor(t/s).

gnuplot Examples:


Method 1:
r = 0.1
n = 32
s = 2*pi/n
f(t) = cos(s*floor(t/s)) + r*cos(n*(t-s*floor(t/s)))
g(t) = sin(s*floor(t/s)) + r*sin(n*(t-s*floor(t/s)))
theta(t) = atan2(g(t), f(t))
set terminal wxt enhanced font "Arial, 10"
set xtics ('-2π' -2*pi, '-π' -pi, '0' 0, 'π' pi, '2π' 2*pi)
set xrange [-2*pi-0.4:2*pi+0.4]
set yrange [-pi-0.2:pi+0.2]
set size ratio -1
set samples 10000
set multiplot
set parametric
unset key
do for [k=-2:2:2]{
  plot [-pi:pi] theta(t) + k*pi, f(t) w p pt 0.5 lc rgb "#0099cc"
}
do for [k=-2:2:2]{
  plot [-pi:pi] theta(t) + k*pi, g(t) w p pt 0.5 lc rgb "#ff00ff"
}
unset multiplot


Method 2:
r = 0.1
n = 32
s = 2*pi/n
f(t) = cos(s*floor(t/s)) + r*cos(n*(t-s*floor(t/s)))
g(t) = sin(s*floor(t/s)) + r*sin(n*(t-s*floor(t/s)))
angle(t) = atan2(g(t), f(t))
theta(t) = angle(t - 2*pi*floor((t+pi)/(2*pi))) + 2*pi*floor((t+pi)/(2*pi))
set terminal wxt enhanced font "Arial, 10"
set xtics ('-2π' -2*pi, '-π' -pi, '0' 0, 'π' pi, '2π' 2*pi)
set xrange [-2*pi-0.4:2*pi+0.4]
set yrange [-pi-0.2:pi+0.2]
set size ratio -1
set samples 10000
set parametric
unset key
plot [-4*pi:4*pi] theta(t), f(t) w p pt 0.5 lc rgb "#0099cc", \
                      theta(t), g(t) w p pt 0.5 lc rgb "#ff00ff"


The result plot:

Graph Examples:

  • Method 1 ( sinusoidal_strings_01.grf )
  • Method 2 ( sinusoidal_strings_02.grf )


( Mathematical softwares used: Graph, gnuplot )