@REM 交点分割
@echo off
REM #jww
REM #cd
REM #ht10
REM #ht30
REM #zz
REM #zw
REM #c切断間隔(図寸)・・・無指定:1/_/a
REM #h2
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 交点分割2.rb temp.txt %1 > jwc_temp.txt
return [kouten_xt,kouten_yt]
end
end
end
def ika3(x)
a=(((x.to_f)*1000).to_i/1000.to_f)
return a
end
sen=[];by=[];zahyo=[];kankaku=1
while ARGV.size >1
case augument=ARGV.pop
when /\/a/
kankaku=augument[2..-1].to_f
end
end
while ARGF.gets
xy =split
if xy[0]=~/^hs/
xy[1..-1].each{|item|by< end
if xy[0]=~/^lg/
lg=xy[0][2,1]
zusun=by[lg.hex]
end
if xy[0]=~/^[0-9]/ or xy[0]=~ /^-/
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2]=xy[2],xy[0]
xy[1],xy[3]=xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
sen << (xy)
end
end
puts"hd"
m=0
open("temp.txt","r"){|f|
while line=f.gets
m += 1
xy=line.split
if xy[0]=~/^hq/
elsif xy[0]=~/^z/
print line
zno=m
z=xy[0]
elsif xy[0]=~/^[0-9]/ or xy[0]=~ /^-/
if zno
m==zno+1 ? zokusei=z : zokusei=""
end
xy.collect!{|item|item.to_f}
if xy[0]>xy[2]
xy[0],xy[2]=xy[2],xy[0]
xy[1],xy[3]=xy[3],xy[1]
elsif xy[0]==xy[2]
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
end
x=xy[2]-xy[0]
y=xy[3]-xy[1]
xyl=Math.sqrt(x**2+y**2)
dx=x/xyl
dy=y/xyl
zahyo=[]
sen.shift
sen.each{|item1|
if kouten(item1,xy) != nil
zahyo << kouten(item1,xy)
end
}
if zahyo.size==0
print line
elsif zahyo.size==1
printf("%10f %10f %10f %10f \n",
xy[0],xy[1],
zahyo[0][0]-kankaku*zusun*dx,
zahyo[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",
xy[2],xy[3],
zahyo[0][0]+kankaku*zusun*dx,
zahyo[0][1]+kankaku*zusun*dy)
else
if xy[0]==xy[2]
zahyo1=zahyo.sort{|a,b| a[1]<=>b[1]}
else
zahyo1=zahyo.sort{|a,b| a[0]<=>b[0]}
end
printf("%10f %10f %10f %10f \n",xy[0],xy[1],zahyo1[0][0]-kankaku*zusun*dx,zahyo1[0][1]-kankaku*zusun*dy)
unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",xy[2],xy[3],zahyo1[-1][0]+kankaku*zusun*dx,zahyo1[-1][1]+kankaku*zusun*dy)
n=0
while n unless zokusei==""
puts zokusei
end
printf("%10f %10f %10f %10f \n",zahyo1[n][0]+kankaku*zusun*dx,zahyo1[n][1]+kankaku*zusun*dy,zahyo1[n+1][0]-kankaku*zusun*dx,zahyo1[n+1][1]-kankaku*zusun*dy)
n+=1
end
end
else
print line
end
end
}
@REM 交点分割
@echo off
REM #jww
REM #cd
REM #ht10
REM #ht30
REM #zz
REM #zc
REM #zw
REM #c切断間隔(図寸)・・・無指定:1/_/a
REM #h2
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 交点分割2.rb temp.txt %1 > jwc_temp.txt
copy jwc_temp.txt temp.txt > nul
ruby -Ks 線_円分割.rb temp.txt %1 > jwc_temp.txt
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
return kakudo
else
return nil
end
end
def sen_en_zahyo(sen,en)
zahyo=[]
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 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]
}
return zahyo
else
return nil
end
end
kankaku=1.0
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
kankaku=argument[2..-1].to_f
end
end
en=[];by=[]
include Math
while ARGF.gets
xy=split
if xy[0]=~/^hs/
xy[1..-1].each{|item|by< end
if xy[0]=~/^lg/
lg=xy[0][2,1];zusun=by[lg.hex]
end
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
x=xy[2]-xy[0]
y=xy[3]-xy[1]
xyl=sqrt(x**2+y**2)
dx=x/xyl
dy=y/xyl
a=[]
en.each{|item|
if sen_en_zahyo(xy,item)
if sen_en_zahyo(xy,item).size==1
a< elsif sen_en_zahyo(xy,item).size>1
a< a< end
end
}
if a.size>0
if xy[0]==xy[2]
b=a.sort{|j,k|j[1] <=> k[1]}
else
b=a.sort{|j,k|j[0] <=> k[0]}
end
0.upto(b.size-2){|i|
puts [b[i][0]+kankaku*zusun*dx,b[i][1]+kankaku*zusun*dy,b[i+1][0]-kankaku*zusun*dx,b[i+1][1]-kankaku*zusun*dy].join("\s")}
puts [xy[0],xy[1],b[0][0]-kankaku*zusun*dx,b[0][1]-kankaku*zusun*dy].join("\s") if xy[0] puts [b[-1][0]+kankaku*zusun*dx,b[-1][1]+kankaku*zusun*dy,xy[2],xy[3]].join("\s") if b[-1][0]+kankaku*zusun*dx else
print $_
end
else
print $_
end
end
}