外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
luaで2点間の距離を計算する(ptdist)
:luaで2点間の距離を計算する(ptdist)
@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 #1-%d 始点を指示してください
REM #2%d 終点を指示してください
REM #e
#!この次の行からプログラムを書いてください
function ptdist(x, y)
local x1, y1 = x[1], x[2]
local x2, y2 = y[1], y[2]
return math.sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
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 string.match(line, "^hp1") then x1, y1 = F[2], F[3] end
if string.match(line, "^hp2") then x2, y2 = F[2], F[3] end
end
printf("h#2点間の距離 L = %.03f", ptdist({x1, y1}, {x2, y2}))