外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
mshtaで線に直交線を引く
:mshtaで線に直交線を引く
@echo off
if exist jwc_temp.txt (
copy jwc_temp.txt myfiles > nul
mshta %~f0 < myfiles > jwc_temp.txt
)
goto:eof
REM #jww
REM #1ln 線を指示してください
REM #bz
REM #e
<script>
function sgn(x) {
return x == 0 ? x : ( x > 0 ? 1 : -1 )
}
function lnlength(x) { //線長を返す
return Math.sqrt(Math.pow(x[3] - x[1], 2) + Math.pow(x[2] - x[0], 2))
}
function lnslope(x) { //線の角度を返す
return Math.atan2(x[3] - x[1], x[2] - x[0])
}
with (new ActiveXObject("Scripting.FileSystemObject")) {
f = GetStandardStream(0) //stdin
g = GetStandardStream(1) //stdout
while (! f.AtEndOfStream) {
F = ($_ = f.ReadLine()).split(/\s+/)
if (/^hp1/i .test($_)) {
p1 = F.slice(1, 3)
if (p1) for (i = 0; i < p1.length; i++) p1[i] *= 1.0;
}
if (/^\s+/i .test($_)) { //ln 指示線
ln1 = F
if (ln1) for (i = 0; i < ln1.length; i++) ln1[i] *= 1.0;
}
}
f.close()
x1 = ln1[0]
y1 = ln1[1]
x2 = ln1[2]
y2 = ln1[3]
p0 = p1
p1 = [x1, y1]
p2 = [x2, y2]
pc = [(x1 + x2) / 2, (y1 + y2) / 2]
l1 = lnlength(p0.concat(p1))
l2 = lnlength(p0.concat(p2))
l3 = lnlength(p0.concat(pc))
if ( (sgn(l2 - l1) + sgn(l3 - l1)) == 2) { pc = p1 }
if ( (sgn(l1 - l2) + sgn(l3 - l2)) == 2) { pc = p2 }
l = lnlength(ln1) / 2
d = lnslope(ln1)
co = Math.cos(d)
si = Math.sin(d)
xc = pc[0]
yc = pc[1]
g.WriteLine("bz")
g.WriteLine([xc + l * si, yc - l * co, xc - l * si, yc + l * co].join(" "))
}
close()
</script>