外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
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 #1-%d 中心を指示してください
REM #2%d 中心線上の外周点を指示してください
REM #e
<script>
function hypot(x, y) { return Math.sqrt(x * x + y * y) }
function fff(a, p) { return a * Math.cos(p) * Math.sqrt(1.0 - 0.5 * Math.pow(Math.sin(p), 2)) }
function ggg(a, p) { return a / Math.sqrt(2.0) * Math.sin(p) * Math.cos(p) }
function hhh(n, p1, p2){
x1 = p1[0] * 1.0
y1 = p1[1] * 1.0
x2 = p2[0] * 1.0
y2 = p2[1] * 1.0
d = Math.atan2(y2 - y1, x2 - x1) + Math.PI / 2.0
si = Math.sin(d)
co = Math.cos(d)
a = hypot(x2 - x1, y2 - y1)
p = 2.0 * Math.PI / n
x = fff(a, 0)
y = ggg(a, 0)
xa = x * si + y * co + x1
ya = -x * co + y * si + y1
i = 1
while (i != n + 1) {
x = fff(a, i * p)
y = ggg(a, i * p)
xb = x * si + y * co + x1
yb = -x * co + y * si + y1
g.WriteLine( [xa, ya, xb, yb].join(" ") )
xa = xb
ya = yb
i++
}
}
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 (/^hp2 /i .test($_)) { p2 = F.slice(1, 3) }
}
f.close()
hhh(100, p1, p2)
}
close()
</script>