In der Vermessung gibt es den sogenannten Richtungswinkel. Das ist der Winkel zwischen der Nordrichtung und der Richtung zu einem anderen Punkt - rechtsläufig.
Gegeben sind die (2D-)-Koordinaten von zwei Punkten, also (Rechtswert und Hochwert). Gesucht ist besagter Richtungswinkel.
Diese Berechnung ist im Grunde einigermaßen einfach, aber es gibt dann Probleme, wenn man den rad in grad oder gon umrechnen will - da muss man dann nämlich die Quadranten beachten.
Ich habe da mal was zusammengetippt, aber beim Abfangen der letzten Spezialfälle für t7 bis 7t9 habe ich eine Blockade. Kann sich das mal bitte jemand ansehen?
Riesen Dank und Viele Grüße
Fabian
Code: Alles auswählen
# Winkelumrechner
def rad_in_grad(rad):
grad = rad / math.pi * 180
return grad
def grad_in_rad(grad):
rad = grad / 180 * math.pi
return rad
def rad_in_gon(rad):
gon = rad / math.pi * 200
return gon
def gon_in_rad(gon):
rad = gon / 200 * math.pi
return rad
def grad_in_gon(grad):
gon = grad * 10/9
return gon
def gon_in_grad(gon):
grad = gon * 9/10
return grad
# Weiteres
def richtungswinkel(a_rechtswert, a_hochwert, e_rechtswert, e_hochwert, einheit='rad'):
delta_hochwert = e_hochwert - a_hochwert
if delta_hochwert == 0:
richtungswinkel = 'n.d.'
else:
richtungswinkel = math.atan( (e_rechtswert - a_rechtswert) / (e_hochwert - a_hochwert) )
if einheit != 'rad':
richtungswinkel = richtungswinkel_umrechnen(richtungswinkel, (e_rechtswert - a_rechtswert), (e_hochwert - a_hochwert), einheit)
return richtungswinkel
# Richtungswinkel von rad in eine andere Winkeleinheit
def richtungswinkel_umrechnen(richtungswinkel, delta_rechtswert, delta_hochwert, einheit='gon'):
zusatzwinkel = 0
q1 = False
q4 = False
if delta_rechtswert == 0 and delta_hochwert > 0:
return 0.0
if delta_hochwert > 0 and delta_rechtswert > 0:
q1 = True
if delta_hochwert > 0 and delta_rechtswert < 0:
q4 = True
if einheit == 'gon':
if q1:
zusatzwert = -200
if q4:
zusatzwert = 200
richtungswinkel = rad_in_gon(richtungswinkel) + 200 + zusatzwinkel
elif einheit == 'grad':
# Wenn du oben fertig bist, dann musst du hier auch noch etwas anpassen, du Lump
richtungswinkel = rad_in_grad(richtungswinkel) + 180 + zusatzwinkel
else:
print(f'Deine Winkeleinheit "{einheit}" hat Fabian noch nicht implementiert, der Pfeifenkopf!')
return richtungswinkel
punkte = [\
[[1, 3], [2, 4]], \ # 1/4*pi 50 gon
[[2, 4], [1, 3]], \ # 1/4*pi 250 gon
[[1, 4], [2, 3]], \ # -1/4*pi 150 gon
[[2, 3], [1, 4]], \ # -1/4*pi 350 gon
[[1, 3], [1, 4]], \ # 0 0 gon !!
[[1, 4], [1, 3]], \ # 0 200 gon !!
[[1, 3], [2, 3]], \ # n.d. 100 gon !!
[[2, 3], [1, 3]], \ # n.d. 300 gon !!
[[1, 1], [1, 1]] \ # n.d. 0 gon !!
]
t1 = richtungswinkel(1, 3, 2, 4)
print(f't1 = {t1} rad')
t1_gon = richtungswinkel(1, 3, 2, 4, 'gon')
print(f't1 = {t1_gon} gon')
t2 = richtungswinkel(2, 4, 1, 3)
print(f't2 = {t2} rad')
t2_gon = richtungswinkel(2, 4, 1, 3, 'gon')
print(f't2 = {t2_gon} gon')
t3 = richtungswinkel(1, 4, 2, 3)
print(f't3 = {t3} rad')
t3_gon = richtungswinkel(1, 4, 2, 3, 'gon')
print(f't3 = {t3_gon} gon')
t4 = richtungswinkel(2, 3, 1, 4)
print(f't4 = {t4} rad')
t4_gon = richtungswinkel(2, 3, 1, 4, 'gon')
print(f't4 = {t4_gon} gon')
t5 = richtungswinkel(1, 3, 1, 4)
print(f't5 = {t5} rad')
t5_gon = richtungswinkel(1, 3, 1, 4, 'gon')
print(f't5 = {t5_gon} gon')
t6 = richtungswinkel(1, 4, 1, 3)
print(f't6 = {t6} rad')
t6_gon = richtungswinkel(1, 4, 1, 3, 'gon')
print(f't6 = {t6_gon} gon')
t7 = richtungswinkel(1, 3, 2, 3)
print(f't7 = {t7} rad')
t7_gon = richtungswinkel(1, 3, 2, 3, 'gon')
print(f't7 = {t7_gon} gon')
t8 = richtungswinkel(2, 3, 1, 3)
print(f't8 = {t8} rad')
# t8_gon = richtungswinkel(2, 3, 1, 3, 'gon')
# print(f't8 = {t8_gon} gon')
t9 = richtungswinkel(1, 1, 1, 1)
print(f't9 = {t9} rad')
# t9_gon = richtungswinkel(1, 1, 1, 1, 'gon')
# print(f't9 = {t9_gon} gon')