diff options
-rw-r--r-- | NOTES.md | 4 | ||||
-rw-r--r-- | __pycache__/poltocart.cpython-35.pyc | bin | 0 -> 943 bytes | |||
-rw-r--r-- | main2.py | 4 | ||||
-rw-r--r-- | poltocart.py (renamed from convert_koordinate.py) | 33 |
4 files changed, 17 insertions, 24 deletions
diff --git a/NOTES.md b/NOTES.md index e4e002f..b18ec21 100644 --- a/NOTES.md +++ b/NOTES.md @@ -3,12 +3,12 @@ ## TODO: - speed -- Kugelkoordinatensysteme (räumliche Polarkoordinaten) +- Kugelkoordinatensysteme (Sphere) * helferklasese ## Notes: -# Umrechnung kartesian - polar +# Umrechnung Cartesian - Sphere koordinatentripel (r, theta, phi) diff --git a/__pycache__/poltocart.cpython-35.pyc b/__pycache__/poltocart.cpython-35.pyc new file mode 100644 index 0000000..0f3e255 --- /dev/null +++ b/__pycache__/poltocart.cpython-35.pyc Binary files differdiff --git a/main2.py b/main2.py index 7745d86..29335d7 100644 --- a/main2.py +++ b/main2.py @@ -6,6 +6,10 @@ import math import numpy as np from timeit import default_timer as timer +# import helper-modules +# convert ploar to cartesian koordinates: +import poltocart as ptc + class TLE: def get(value, category, satNr): with open('TLE/' + category + '.txt') as data: diff --git a/convert_koordinate.py b/poltocart.py index b5e52e3..2db6723 100644 --- a/convert_koordinate.py +++ b/poltocart.py @@ -1,22 +1,16 @@ # import -import math import numpy as np import matplotlib.pyplot as plt -# pol[x, y, z] -x = 1 -y = 2 -z = 3 -pol = [x, y, z] - # define r, theta, phi r = 0 theta = 0 phi = 0 -kart = [0, 0, 0] +cart = [r, theta, phi] + +def poltocart(pol): + print(pol) -def poltokart(pol): - # split up list x = pol[0] y = pol[1] z = pol[2] @@ -25,28 +19,23 @@ def poltokart(pol): r = np.sqrt(np.power(x, 2) + np.power(y, 2) + np.power(z, 2)) # theta - a = np.sqrt(x^2 + y^2 + z^2) - b = ((z) / a) - b = b * math.pi / 180 - theta = np.arccos(b) + theta = np.arccos( z / r ) # phi if x > 0: phi = np.arctan(y/x) elif x == 0: - phi = np.sign(y)*(math.pi/2) + phi = np.sign(y)*(np.pi/2) elif x < 0 and y >= 0: phi = np.arctan(y/x) + math.pi elif x < 0 and y < 0: phi = np.arctan(y/x) - math.pi # write to cartesian list - kart[0] = r - kart[1] = theta - kart[2] = phi + cart[0] = r + cart[1] = theta + cart[2] = phi -# run -poltokart(pol) + return cart -print("{:<15}{:<60}".format("polar:", str(pol) )) -print("{:<15}{:<60}".format("cartesian:", str(kart) )) +poltocart([4, 3, 5]) |