aboutsummaryrefslogtreecommitdiffstats
path: root/buch/papers/nav/images/pk.m
diff options
context:
space:
mode:
authorAndreas Müller <andreas.mueller@ost.ch>2022-05-11 22:13:59 +0200
committerAndreas Müller <andreas.mueller@ost.ch>2022-05-11 22:13:59 +0200
commita7a12c313b1a4fb528337eb354668e69d6d20942 (patch)
treef877d331b1054cbcb1216025ec5641b312513ab8 /buch/papers/nav/images/pk.m
parentFresnel-Präsentation (diff)
downloadSeminarSpezielleFunktionen-a7a12c313b1a4fb528337eb354668e69d6d20942.tar.gz
SeminarSpezielleFunktionen-a7a12c313b1a4fb528337eb354668e69d6d20942.zip
dreiecksgraphik
Diffstat (limited to '')
-rw-r--r--buch/papers/nav/images/pk.m55
1 files changed, 55 insertions, 0 deletions
diff --git a/buch/papers/nav/images/pk.m b/buch/papers/nav/images/pk.m
new file mode 100644
index 0000000..6e89e9a
--- /dev/null
+++ b/buch/papers/nav/images/pk.m
@@ -0,0 +1,55 @@
+#
+# pk.m -- Punkte und Kanten für sphärisches Dreieck
+#
+# (c) 2021 Prof Dr Andreas Müller, OST Ostschweizer Fachhochschule
+#
+
+A = [ 1, 8 ];
+B = [ -3, 3 ];
+C = [ 4, 4 ];
+P = [ 0, 0 ];
+
+global fn;
+fn = fopen("dreieckdata.tex", "w");
+
+fprintf(fn, "\\coordinate (P) at (%.4f,%.4f);\n", P(1,1), P(1,2));
+fprintf(fn, "\\coordinate (A) at (%.4f,%.4f);\n", A(1,1), A(1,2));
+fprintf(fn, "\\coordinate (B) at (%.4f,%.4f);\n", B(1,1), B(1,2));
+fprintf(fn, "\\coordinate (C) at (%.4f,%.4f);\n", C(1,1), C(1,2));
+
+function retval = seite(A, B, l, nameA, nameB)
+ global fn;
+ d = fliplr(B - A);
+ d(1, 2) = -d(1, 2);
+ # Zentrum
+ C = 0.5 * (A + B) + l * d;
+ # Radius:
+ r = hypot(C(1,1)-A(1,1), C(1,2)-A(1,2))
+ # Winkel von
+ winkelvon = atan2(A(1,2)-C(1,2),A(1,1)-C(1,1));
+ # Winkel bis
+ winkelbis = atan2(B(1,2)-C(1,2),B(1,1)-C(1,1));
+ if (abs(winkelvon - winkelbis) > pi)
+ if (winkelbis < winkelvon)
+ winkelbis = winkelbis + 2 * pi
+ else
+ winkelvon = winkelvon + 2 * pi
+ end
+ end
+ # Kurve
+ fprintf(fn, "\\def\\kante%s%s{(%.4f,%.4f) arc (%.5f:%.5f:%.4f)}\n",
+ nameA, nameB,
+ A(1,1), A(1,2), winkelvon * 180 / pi, winkelbis * 180 / pi, r);
+ fprintf(fn, "\\def\\kante%s%s{(%.4f,%.4f) arc (%.5f:%.5f:%.4f)}\n",
+ nameB, nameA,
+ B(1,1), B(1,2), winkelbis * 180 / pi, winkelvon * 180 / pi, r);
+endfunction
+
+seite(A, B, -1, "A", "B");
+seite(A, C, 1, "A", "C");
+seite(A, P, -1, "A", "P");
+seite(B, C, -2, "B", "C");
+seite(B, P, -1, "B", "P");
+seite(C, P, 2, "C", "P");
+
+fclose(fn);