外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
javaで線角を計算する(lnslope)
:javaで線角を計算する(lnslope)
@echo off
if not exist %~dp0LnSlope.class (
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
more +%%n %0 > %~dpn0.java
javac -encoding shift_jis %~dpn0.java
)
)
copy jwc_temp.txt myfiles > nul
java -Dfile.encoding=shift_jis -classpath %~dp0 LnSlope > jwc_temp.txt
goto:eof
REM #jww
REM #1ln 基準線を指示してください
REM #e
#!この次の行からプログラムを書いてください
import java.io.*;
import java.util.regex.Pattern;
class LnSlope {
public static void main(String args) {
try {
BufferedReader f = new BufferedReader(new FileReader("myfiles"));
String line;
double hk = 0.0;
int i = 1;
String ln = new String[10][4];
while ((line = f.readLine()) != null) {
if (Pattern.compile("^hk").matcher(line).find()) {
hk = Double.parseDouble(line.substring(2));
continue;
}
if (Pattern.compile("^ ").matcher(line).find()) {
String p = line.trim().split(" ");
if (p.length == 4) {
ln[i++] = p;
}
}
}
f.close();
double x1, y1, x2, y2, d;
x1 = Double.parseDouble(ln[1][0]);
y1 = Double.parseDouble(ln[1][1]);
x2 = Double.parseDouble(ln[1][2]);
y2 = Double.parseDouble(ln[1][3]);
d = Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI - hk;
System.out.printf("h#∠ = %.3f゚\n", d);
} catch (IOException e) {
System.out.println(e);
}
}
}