# setting the parametric indication
set parametric
# setting the grid
set grid
# setting the aspect ratio of graph
set size ratio -1
# setting the start angle of Archimedes spiral
# ''θ0'' and end angle ''θ1'' [rad]
t0=8*pi # lower limits of integral interval
t1=100 # upper limits of integral interval
# setting the numbers of sample
N=10000 # divided numbers of integral interval
# setting the rotation angle of inner end a [rad]
a=5.5
# entire length of hairspring L
L=0.5*(t1*sqrt(1+t1**2)+log(t1+sqrt(1+t1**2))\
-t0*sqrt(1+t0**2)-log(t0+sqrt(1+t0**2)))
# integrand of real part
f(t)=h*(t*cos(t)*sin(Q)+t*sin(t)*cos(Q))
#integrand of imaginary part
g(t)=-h*(t*cos(t)*cos(Q)-t*sin(t)*sin(Q))
# setting the integral range
set trange [t0:t1]
set samples N+1
# writing down the data to separate file
# ( x and y coordinates after distortion )
set table "table10.txt"
plot lastx=0.0,lastyr=0.0,lastyi=0.0,integr = 0.0,\
integi = 0.0,old1=0,old2=0,old3=0,\integzr=0,\
integzi=0,integzr2=0,integzi2=0,integL=0,zr=0,\
zi=0,Qold=a,\
"+" using 1 : (dx=$1-lastx, \
s=0.5*($1*sqrt(1+$1**2)+log($1+sqrt(1+$1**2))\
-t0*sqrt(1+t0**2)-log(t0+sqrt(1+t0**2))),\
Q=a*(L-s)/L\+0.0001211*($1-t0)*\
(sin(0.909341*$1+17.6221)-1.06),\
h=(Q-Qold)/dx,\
integr = ($0==0 ? 0.0:integr+dx*(f($1)+lastyr)*0.5), \
integi = ($0==0 ? 0.0:integi+dx*(g($1)+lastyi)*0.5), \
lastx=$1, \
lastyr=f($1),\
lastyi=g($1),\
zr=integr+$1*cos($1)*cos(Q)-$1*sin($1)*sin(Q),\
zi=integi+$1*cos($1)*sin(Q)+$1*sin($1)*cos(Q),\
dzx=($0==0 ? 0.0 : zr-old1),\
dzy=($0==0 ? 0.0 : zi-old2),\
dL=sqrt(dzx**2+dzy**2),\
integzr=integzr+(zr+old1)*0.5*dL,\
integzi=integzi+(zi+old2)*0.5*dL,\
integzr2=integzr2+(zr**2+old1**2)*0.5*dL,\
integzi2=integzi2+(zi**2+old2**2)*0.5*dL,\
integL=dL+old3,\
old1=zr,\
old2=zi,\
old3=integL,\
Qold=Q,\
Ihx=integzi2/L-(integzi/L)**2,\
Ihy=integzr2/L-(integzr/L)**2,\
zr) : (zi) : (integL) : (integzr/L):(integzi/L) \
w xyerrorbars
unset table
# setting the kinds of lines of graph
set style line 1 linetype 1
set style line 1 linecolor -1
set style line 1 linewidth 2
set style line 2 linetype 1
set style line 2 linecolor 1
set style line 2 linewidth 1
# setting the range of x and y axes
set xrange [-150:150]
set yrange [-150:150]
# setting the label of x and y axes
set xlabel "x/a"
set ylabel "y/a"
# drawing the graph
plot "table10.txt" u 2:3 w l linestyle 1 notitle
# drawing the coordinates of the center of gravity
replot integzr/L,integzi/L w p title "G(x,y)"
# drawing the collet
replot t0* cos(t),t0*sin(t) w l linestyle 2 notitle
# designating the output format and option
set terminal jpeg
# designating the output file name
set output "koteitanhige5.jpeg"
# regraphing
replot
# resetting the format and output
set output
set terminal win