@REM パラメトリック回転
@echo off
REM #jww
REM #cd
REM #h2
REM #c角度を入力してください・・・無指定:0:/_/a
REM #k方向を選択してください・・・|1)X方向(L)|2)Y方向(R)|3)任意方向| /_/b
REM #0基準点を指示してください
REM #1移動点を指示してください
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks パラメ回転.rb temp.txt %1 %2 > jwc_temp.txt
◎スクリプトファイル(ファイル名 パラメ回転.rb)
BEGIN{
puts"hd"
$kaiten =0 #回転角度のデフォルト値(0°)
while ARGV.length > 1
case argument = ARGV.pop
when /^\/a/
$kaiten = argument[ 2 .. -1].to_f
when /^\/b/
$houkou = argument[ 2 .. -1]
end
end
$kakudo=(2*Math::PI/360)*$kaiten
}
def sen( x1, y1, x2, y2 )
printf("%.10f %.10f %.10f %.10f\n", x1, y1, x2, y2)
end
include Math
while ARGF.gets
xy=split
if xy[0]=~/^hq/
elsif xy[0]=~/^hn/
xy.collect!{|item|item.to_f}
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
if xy[2]>xy[4]
xy[4],xy[2]=xy[2],xy[4]
end
hnx1=xy[1].to_f
hny1=xy[2].to_f
hnx2=xy[3].to_f
hny2=xy[4].to_f
elsif xy[0]=~/^hp/
if $houkou=="1"
hpx=xy[1].to_f
hpy=0
elsif $houkou=="2"
hpx=0
hpy=xy[2].to_f
else
hpx=xy[1].to_f
hpy=xy[2].to_f
end
elsif xy[0]=~/^[0-9]/ or xy[0]=~/^-/
xy.collect!{|item|item.to_f}
if xy[2] xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
elsif xy[2]==xy[0]
if xy[3] xy[3],xy[1]=xy[1],xy[3]
end
end
if xy[1]==xy[3] or xy[1] if (hnx1xy[2] &&
hny1xy[3])
x1=xy[0]
y1=xy[1]
xyl1=sqrt(x1**2+y1**2)
kakudo1=atan2(y1,x1)
x2=xy[2]
y2=xy[3]
xyl2=sqrt(x2**2+y2**2)
kakudo2=atan2(y2,x2)
sen(hpx+xyl1*cos($kakudo+kakudo1),
hpy+xyl1*sin($kakudo+kakudo1),
hpx+xyl2*cos($kakudo+kakudo2),
hpy+xyl2*sin($kakudo+kakudo2))
elsif hnx1xy[0] &&
hnx2 hny2>xy[1]
x=xy[0]
y=xy[1]
xyl=sqrt(x**2+y**2)
senkakudo=atan2(y,x)
sen(hpx+xyl*cos($kakudo+senkakudo),
hpy+xyl*sin($kakudo+senkakudo),
xy[2],xy[3])
elsif hnx1xy[0] && hny1 hny2>xy[1]
x=xy[0]
y=xy[1]
xyl=sqrt(x**2+y**2)
senkakudo=atan2(y,x)
sen(hpx+xyl*cos($kakudo+senkakudo),
hpy+xyl*sin($kakudo+senkakudo),
xy[2],xy[3])
elsif hnx1xy[2] &&
hny1xy[3] && hnx1>xy[0]
x=xy[2]
y=xy[3]
xyl=sqrt(x**2+y**2)
senkakudo=atan2(y,x)
sen(xy[0],xy[1],
hpx+xyl*cos($kakudo+senkakudo),
hpy+xyl*sin($kakudo+senkakudo))
elsif hnx1xy[0] && hny1>xy[1] &&
hny2>xy[3]
x=xy[2]
y=xy[3]
xyl=sqrt(x**2+y**2)
senkakudo=atan2(y,x)
sen(xy[0],xy[1],
hpx+xyl*cos($kakudo+senkakudo),
hpy+xyl*sin($kakudo+senkakudo))
else
print $_
end
elsif xy[1]>xy[3]
if (hnx1xy[2] &&
hny2>xy[1] && hny1 xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
x1=xy[0]
y1=xy[1]
xyl1= sqrt(x1**2+y1**2)
kakudo1= atan2(y1,x1)
x2=xy[2]
y2=xy[3]
xyl2= sqrt(x2**2+y2**2)
kakudo2= atan2(y2,x2)
sen(hpx+xyl1* cos($kakudo+kakudo1),
hpy+xyl1* sin($kakudo+kakudo1),
hpx+xyl2* cos($kakudo+kakudo2),
hpy+xyl2* sin($kakudo+kakudo2))
elsif hnx1xy[0] &&
hnx2xy[1]
xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
x=xy[2]
y=xy[3]
xyl= sqrt(x**2+y**2)
senkakudo= atan2(y,x)
sen(hpx+xyl* cos($kakudo+senkakudo),
hpy+xyl* sin($kakudo+senkakudo),
xy[0],xy[1])
elsif hnx1xy[0] && hny2>xy[1] &&
hny1 xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
x=xy[2]
y=xy[3]
xyl= sqrt(x**2+y**2)
senkakudo= atan2(y,x)
sen(hpx+xyl* cos($kakudo+senkakudo),
hpy+xyl* sin($kakudo+senkakudo),
xy[0],xy[1])
elsif hnx1xy[2] &&
hny1xy[3] && hnx1>xy[0]
xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
x=xy[0]
y=xy[1]
xyl= sqrt(x**2+y**2)
senkakudo= atan2(y,x)
sen(hpx+xyl* cos($kakudo+senkakudo),
hpy+xyl* sin($kakudo+senkakudo),
xy[2],xy[3])
elsif hnx1xy[0] && hny2>xy[3] &&
hny1 xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
x=xy[0]
y=xy[1]
xyl= sqrt(x**2+y**2)
senkakudo= atan2(y,x)
sen(hpx+xyl* cos($kakudo+senkakudo),
hpy+xyl* sin($kakudo+senkakudo),
xy[2],xy[3])
else
print $_
end
end
else
print $_
end
end
@REM パラメトリック回転
@echo off
REM #jww
REM #cd
REM #ht10
REM #zz
REM #h2
REM #c角度を入力してください・・・無指定:0:/_/a
REM #k方向を選択してください・・・|1)X方向(L)|2)Y方向(R)|3)任意方向| /_/b
REM #0基準点を指示してください
REM #1移動点を指示してください
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks パラメ回転.rb temp.txt %1 %2 > jwc_temp.txt
◎スクリプトファイル(ファイル名 パラメ回転.rb)
BEGIN{
puts"hd"
$kaiten =0 #回転角度のデフォルト値(0°)
while ARGV.length > 1
case argument = ARGV.pop
when /^\/a/
$kaiten = argument[ 2 .. -1].to_f
when /^\/b/
$houkou = argument[ 2 .. -1]
end
end
$kakudo=(2*Math::PI/360)*$kaiten
}
def sen( x1, y1, x2, y2 )
printf("%.10f %.10f %.10f %.10f\n", x1, y1, x2, y2)
end
include Math
while ARGF.gets
xy=split
if xy[0]=~/^hq/
elsif xy[0]=~/^hn/
xy.collect!{|item|item.to_f}
if xy[1]>xy[3]
xy[1],xy[3]=xy[3],xy[1]
end
if xy[2]>xy[4]
xy[4],xy[2]=xy[2],xy[4]
end
hnx1=xy[1].to_f
hny1=xy[2].to_f
hnx2=xy[3].to_f
hny2=xy[4].to_f
elsif xy[0]=~/^hp/
if $houkou=="1"
hpx=xy[1].to_f
hpy=0
elsif $houkou=="2"
hpx=0
hpy=xy[2].to_f
else
hpx=xy[1].to_f
hpy=xy[2].to_f
end
elsif xy[0]=~/^[0-9]/ or xy[0]=~/^-/
xy.collect!{|item|item.to_f}
if xy[2] xy[2],xy[0],xy[3],xy[1]=xy[0],xy[2],xy[1],xy[3]
elsif xy[2]==xy[0]
if xy[3] xy[3],xy[1]=xy[1],xy[3]
end
end
n=0
while n if hnx1xy[n] &&
hny1xy[n+1]
xyl=sqrt(xy[n]**2+xy[n+1]**2)
iti_kakudo=atan2(xy[n+1],xy[n])
xy[n]=hpx+xyl*cos(iti_kakudo+$kakudo)
xy[n+1]=hpy+xyl*sin(iti_kakudo+$kakudo)
end
n+=2
end
puts xy.join("\s")
elsif xy[0]=~/^ci/
eniti=sqrt((xy[1].to_f)**2+(xy[2].to_f)**2)
enkakudo=atan2(xy[2].to_f,xy[1].to_f)
r=xy[2].to_f
if xy.size==4
printf("ci %.10f %.10f %.10f \n",
hpx+eniti*cos(enkakudo+$kakudo),
hpy+eniti*sin(enkakudo+$kakudo),r)
elsif xy.size==8
sikaku=xy[4].to_f;syukaku=xy[5].to_f;hen=xy[6].to_f
ziku=xy[7].to_f
printf("ci %.10f %.10f %.10f %.10f %.10f %.10f %.10f\n",
hpx+eniti*cos(enkakudo+$kakudo),
hpy+eniti*sin(enkakudo+$kakudo),r,
sikaku,syukaku,hen,ziku+$kaiten)
end
elsif xy[0]=~/^pt/
teniti=sqrt((xy[1].to_f)**2+(xy[2].to_f)**2)
tenkakudo=atan2(xy[2].to_f,xy[1].to_f)
printf("pt %.10f %.10f \n",
hpx+teniti*cos(tenkakudo+$kakudo),
hpy+teniti*sin(tenkakudo+$kakudo))
elsif xy[0]=~/^ch/ or xy[0]=~/^cs/
if $_=~/\"/
moji=$'
end
mojiiti=sqrt((xy[1].to_f)**2+(xy[2].to_f)**2)
mojiiti_kakudo=atan2(xy[2].to_f,xy[1])
mojil=sqrt((xy[4].to_f)**2+(xy[3].to_f)**2)
mojikakudo=atan2(xy[4].to_f,xy[3].to_f)
printf("ch %.10f %.10f %s %s \"%s\n",
hpx+mojiiti*cos(mojiiti_kakudo+$kakudo),
hpy+mojiiti*sin(mojiiti_kakudo+$kakudo),
mojil*cos(mojikakudo+$kakudo),
mojil*sin(mojikakudo+$kakudo),moji)
elsif xy[0]=~/^sl/
xy.shift
xy.collect!{|item|item.to_f}
n=0
while n if hnx1xy[n] &&
hny1xy[n+1]
sliti=sqrt(xy[n]**2+xy[n+1]**2)
slkakudo=atan2(xy[n+1],xy[n])
xy[n]=hpx+sliti*cos(slkakudo+$kakudo)
xy[n+1]=hpy+sliti*sin(slkakudo+$kakudo)
end
n+=2
end
xy.unshift("sl")
puts xy.join("\s")
else
print $_
end
end