@REM 円内の直線を消去
@echo off
REM #jww
REM #cd
REM #ht10
REM #ht30
REM #zz
REM #zw
REM #hp
REM #h2
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 円内消去.rb temp.txt > jwc_temp.txt
if sen_x1>sen_x2
sen_x1,sen_x2=sen_x2,sen_x1
sen_y1,sen_y2=sen_y2,sen_y1
elsif sen_x1==sen_x2
if sen_y1>sen_y2
sen_y1,sen_y2=sen_y2,sen_y1
end
end
senx=(sen_x2-sen_x1)
seny=(sen_y2-sen_y1)
sen_kakudo2=atan2(seny,senx)
if en_xy2_1>r && (sen_x1 cos(kakudo1+sen_kakudo2) &&sen_x2>en[1]+r*
cos(kakudo1+sen_kakudo2) or
sen_y1 sin(kakudo1+sen_kakudo2) &&sen_y2>en[2]+r*
sin(kakudo1+sen_kakudo2))
kakudo<<(kakudo1+sen_kakudo2)*360/(2*PI)+ziku
end
if en_xy2_2>r && (sen_x2>en[1]+r*
cos(kakudo2+sen_kakudo2) &&sen_x1 cos(kakudo2+sen_kakudo2) or
sen_y2>en[2]+r*
sin(kakudo2+sen_kakudo2) &&
sen_y1 kakudo<<(kakudo2+sen_kakudo2)*360/(2*PI)+ziku
end
end
if en.size==4
x=en[1]
y=en[2]
r=en[3]
en[4]=0
en[5]=0
en[6]=1
en[7]=0
else
x=en[1]
y=en[2]
r=en[3]
end
hen=en[6]
ziku=en[7]
kakudo=sen_en_kakudo(sen,en) if sen_en_kakudo(sen,en)
if kakudo
kakudo.each{|item| rajian=item*2*PI/360
ziku_arg=ziku*2*PI/360
ax=r*cos(rajian-ziku_arg)
ay=r*sin(rajian-ziku_arg)*hen
axy=sqrt(ax**2+ay**2)
arg=atan2(ay,ax)
axt=x+axy*cos(arg+ziku_arg)
ayt=y+axy*sin(arg+ziku_arg)
zahyo<<[axt,ayt]
}
end
if zahyo.size>0
return zahyo
else
nil
end
end
#tenの位置がenの内(true)か、外(false)かを判定
def area(en,ten)
zahyo=[]
zahyo< if zahyo.flatten.size==2
return true
else
return false
end
end
en=[];naigai=[]
while ARGF.gets
xy=split
if xy[0]=~/^ci/
xy.collect!{|item|item.to_f}
en< end
end
puts "hd"
open("temp.txt","r"){|f|
while line=f.gets
xy=line.split
if xy[0]=~/^hq/
elsif xy[0]=~/^\d/
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2],xy[1],xy[3]=xy[2],xy[0],xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
kouten=[]
en.each{|item|
if sen_en_zahyo(xy,item)!=nil
if sen_en_zahyo(xy,item).size==2
kouten<<[sen_en_zahyo(xy,item)[0][0],sen_en_zahyo(xy,item)[0][1]]
kouten<<[sen_en_zahyo(xy,item)[1][0],sen_en_zahyo(xy,item)[1][1]]
elsif sen_en_zahyo(xy,item).size==1
kouten<<[sen_en_zahyo(xy,item)[0][0],sen_en_zahyo(xy,item)[0][1]]
end
end
}
if xy[0]==xy[2]
kouten2=kouten.sort{|a,b|a[1]<=>b[1] }
else
kouten2=kouten.sort{|a,b|a[0]<=>b[0] }
end
area1=0;area2=0
en.each{|item|
if area(item,[xy[0],xy[1]])==true
area1+=1
end
if area(item,[xy[2],xy[3]])==true
area2+=1
end
}
if area1==0 && kouten2.size>0
printf("%.11f %.11f %.11f %.11f\n",xy[0],xy[1],kouten2[0][0],kouten2[0][1])
end
if area2==0 && kouten2.size>0
printf("%.11f %.11f %.11f %.11f\n",xy[2],xy[3],kouten2[-1][0],kouten2[-1][1])
end
if kouten2.size>1
area1==0 ? n1=1 : n1=0
area2==0 ? n2=kouten2.size-3 : n2=kouten2.size-2
n1.step(n2,2){|i|printf("%.11f %.11f %.11f %.11f\n",kouten2[i][0],kouten2[i][1],kouten2[i+1][0],kouten2[i+1][1])}
end
if kouten.size==0 && area1==0 && area2==0
print line
end
naigai< else
print line
end
end
}
@REM 円間を線で結ぶ
@echo off
REM #jww
REM #cd
REM #h1
REM #1最初の円の中心を指示してください
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks ci-ci.rb temp.txt > jwc_temp.txt
◎スクリプトファイル(ファイル名 ci-ci.rb)
include Math
en=[];data=[]
while ARGF.gets
xy=split
if xy[0]=~/^hp/
hpx,hpy=xy[1].to_f,xy[2].to_f
end
if xy[0]=~/^ci/
en<<[xy[1].to_f,xy[2].to_f,xy[3].to_f]
end
end
x2_1=a[0]+a[2]*cos(arg);y2_1=a[1]+a[2]*sin(arg)
x2_2=en[0][0]-en[0][2]*cos(arg);y2_2=en[0][1]-en[0][2]*sin(arg)
data<<[x2_1,y2_1,x2_2,y2_2]
a=en.shift
end