@REM 三角形の変形(斜辺一定・底辺伸縮)
@echo off
REM #jww
REM #cd
REM #hp
REM #1底辺の始点を指示してください(時計回り) free(L) Read(R)
REM #2底辺の終点を指示してください(時計回り) free(L) Read(R)
REM #3頂点の位置を指示してください(時計回り) free(L) Read(R)
REM #c高さを何等分しますか? 無指定:10/_/a
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -x %~f0 temp.txt %1 > jwc_temp.txt
exit
#!ruby -Ks
include Math
n=10
while ARGV.size>1
case argument=ARGV.pop
when /\/a/
n=argument[2..-1].to_i
end
end
while ARGF.gets
xy=split
if xy[0]=~/^hp/
if xy[0]=="hp1"
x1,y1=xy[1].to_f,xy[2].to_f
elsif xy[0]=="hp2"
x2,y2=xy[1].to_f,xy[2].to_f
elsif xy[0]=="hp3"
x3,y3=xy[1].to_f,xy[2].to_f
end
end
end
l1=hypot(y3-y2,x3-x2)
l2=hypot(y3-y1,x3-x1)
sen_arg=atan2(y1-y2,x1-x2)
arg1=atan2(y3-y2,x3-x2)
henkaku1=arg1-sen_arg
h1=l1*sin(henkaku1)
lt=l1*cos(henkaku1)
tyuten_x=x2+lt*cos(sen_arg)
tyuten_y=y2+lt*sin(sen_arg)
h2=0
n.times{
h2 += (h1/n)
x7=tyuten_x+h2*cos(sen_arg+PI/2)
y7=tyuten_y+h2*sin(sen_arg+PI/2)
l5 = sqrt((l1**2)-(h2**2))
l6 = sqrt((l2**2)-(h2**2))
x5=tyuten_x-l5*cos(sen_arg)
y5=tyuten_y-l5*sin(sen_arg)
x6=tyuten_x+l6*cos(sen_arg)
y6=tyuten_y+l6*sin(sen_arg)
#printf("%.11f %.11f %.11f %.11f\n",x5,y5,x6,y6)
printf("%.11f %.11f %.11f %.11f\n",x7,y7,x5,y5)
printf("%.11f %.11f %.11f %.11f\n",x7,y7,x6,y6)
}