From 6609420bf03972212cbfaeb6b53eee66a478e7bf Mon Sep 17 00:00:00 2001
From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de>
Date: Sun, 12 May 2024 01:12:16 +0200
Subject: [PATCH] drop some topic

---
 python-grundlage/horner.py              |   32 ++++++++++++++++
 .gitignore                              |    2 +
 python-grundlage/petal.py               |    8 ++--
 python-grundlage/dice-simulation.py     |    7 ++-
 python-grundlage/cartesian2polar.py     |   16 ++++++++
 python-grundlage/polynom.txt            |   10 +++++
 python-grundlage/mecartor-projection.py |   31 +++++++++++++++
 7 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f282e9f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+sandbox*
+queens*
\ No newline at end of file
diff --git a/python-grundlage/cartesian2polar.py b/python-grundlage/cartesian2polar.py
new file mode 100755
index 0000000..36e809f
--- /dev/null
+++ b/python-grundlage/cartesian2polar.py
@@ -0,0 +1,16 @@
+#! /usr/bin/env python
+import sys
+import math
+
+
+x = float(sys.argv[1])
+y = float(sys.argv[2])
+
+z = complex(x, y)
+radius = abs(z)
+theta = math.atan2(y, x)
+theta_degree = math.degrees(theta)
+
+print("Kartesische Koordinate des Punktes:")
+print(f"   x = {x}; y = {y}")
+print(f"   r = {radius:.3f}; theta = {theta_degree:.3f}°")
diff --git a/python-grundlage/dice-simulation.py b/python-grundlage/dice-simulation.py
index b02256e..78fc39a 100644
--- a/python-grundlage/dice-simulation.py
+++ b/python-grundlage/dice-simulation.py
@@ -10,7 +10,10 @@
 print(absolute_frequency)
 
 relative_frequency = tuple(
-    (f[0], f[1]/experiments) for f in absolute_frequency
+    (freq[0], freq[1] / experiments) for freq in absolute_frequency
 )
-
 print(relative_frequency)
+
+relative_frequency = tuple(
+    (absolute_frequency[idx][0], absolute_frequency[idx][1] / experiments) for idx in range(1, 6 + 1)
+)
\ No newline at end of file
diff --git a/python-grundlage/horner.py b/python-grundlage/horner.py
new file mode 100755
index 0000000..27a7470
--- /dev/null
+++ b/python-grundlage/horner.py
@@ -0,0 +1,32 @@
+#! /usr/bin/env python
+
+from sys import stdin
+
+# read polynome from stdin
+print(f"Input Coefficients line by line, last line is x0, Press Ctr+D to finish!")
+lines = []
+for line in stdin:
+    koeffizient = line.strip()
+    if koeffizient[0] == "#":
+        continue
+    if len(koeffizient) > 0:
+        lines.append(float(koeffizient))
+    else:
+        break
+
+a = lines[0:-1]
+b = lines[-1]
+b = float(b)
+p = a[-1]
+c = [p]
+for ak in a[-2::-1]:
+    p = ak + (p * b)
+    c.insert(0, p)
+
+
+p_b = c[0]
+c = c[1:]
+print(f"p(x) =", a)
+print(f"p({b}) = {p_b}")
+print(f"c(x) =", c)
+
diff --git a/python-grundlage/mecartor-projection.py b/python-grundlage/mecartor-projection.py
new file mode 100644
index 0000000..8cf654e
--- /dev/null
+++ b/python-grundlage/mecartor-projection.py
@@ -0,0 +1,31 @@
+#! /usr/bin/env python
+
+"""
+Usage:
+python mecartor-projection <latitude> <longitude>
+Example Bundestags Kooridnaten: 52°31'7.22" N 13°22'13.69" E
+./mecartor-projection.py 52.5186729836 13.3704687765
+x = 5.55928
+y = 18.86398
+"""
+from math import log, tan, radians, pi
+import sys
+from typing import Final
+
+# Sternwarte Peterberg WGS84 (49° 34′ N, 7° 0′ E)
+MAP_CENTER_LONGITUDE: Final[float] = radians(7)
+
+RADIUS: Final[float] = 50  # cm
+
+latitude = float(sys.argv[1])  # Degree
+longitude = float(sys.argv[2])  # Degree
+
+# Hilfe-Variablen
+lat = radians(latitude)
+lon = radians(longitude)
+# Kartesische Koordinaten
+x: float = RADIUS * (lon - MAP_CENTER_LONGITUDE)
+y: float = RADIUS * log(tan(pi/4) + lat/2)
+
+print(f"x = {x:.5f}")
+print(f"y = {y:.5f}")
diff --git a/python-grundlage/petal.py b/python-grundlage/petal.py
index 76e0ec4..6a2ce83 100644
--- a/python-grundlage/petal.py
+++ b/python-grundlage/petal.py
@@ -2,18 +2,18 @@
 import turtle
 import math
 
-num_of_petal = 60
+num_of_petal = 5
 petal_length = 100
 # winkel sind in Degree
-alpha = 90 / num_of_petal
+alpha = 90 / (num_of_petal-1)
 beta = 2 * alpha
 gamma = 180 - beta
 
 # abgeleitete Länge
 side_length = petal_length * math.cos(math.radians(alpha))
-
+start_angle = 0
 for petal in range(0, num_of_petal):
-    direction = petal * (360 / num_of_petal)
+    direction = petal * (360 / num_of_petal) + start_angle
     turtle.home()
     turtle.left(direction + alpha)
     turtle.fd(side_length)
diff --git a/python-grundlage/polynom.txt b/python-grundlage/polynom.txt
new file mode 100644
index 0000000..9b212e6
--- /dev/null
+++ b/python-grundlage/polynom.txt
@@ -0,0 +1,10 @@
+# Koefizient
+4
+0
+2
+0
+0
+-3
+6
+# x0 =
+2

--
Gitblit v1.10.0-SNAPSHOT