外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
luaで線角を計算する(lnslope)
:luaで線角を計算する(lnslope)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
copy jwc_temp.txt myfiles > nul
more +%%n %0 | lua > jwc_temp.txt
)
goto:eof
REM #jww
REM #1ln 基準線を指示してください
REM #e
#!この次の行からプログラムを書いてください
function lnslope(s) --線の角度を返す
local x1, y1, x2, y2 = s[1], s[2], s[3], s[4]
return math.atan2(y2 - y1, x2 - x1)
end
function sprintf(...)
if #{...} == 0 then return end
if #{...} == 1 then return ... end
return string.format(...)
end
function printf(...)
return print(sprintf(...))
end
for line in io.lines("myfiles") do
F = {}
string.gsub(line, "%S+", function (x) table.insert(F, x) end)
if line:match("^hk") then
hk = F[2]
end
if string.match(line, "^ ") then
printf("h#∠ = %.03f゚", math.deg(lnslope(F)) - hk)
end
end