M.2.I
1. Betrag und Winkelposition
Gegeben ist das grüne Bezugssystem und ein Vektor über seine \((x,y)\)-Komponenten.

Berechnen Sie:
den Betrag \(v\) des Vektors und
die Winkelposition \(-180^\circ < \varphi \le 180^\circ,\) des Vektors - und zwar in \(^\circ\) (Grad).
Runden Sie jeweils auf Rundestellenwert \(0{,}1\):
Gegeben ist das grüne Bezugssystem und ein Vektor über seine \((v,\varphi)\)-Komponenten (Polarkoordinaten). Berechnen Sie die \((x,y)\)-Komponenten (Kartesische Koordinaten) \(v_x\) und \(v_y\) - und zwar gerundet auf Rundestellenwert \(0{,}01\):
Copy: Source Code (siehe unten) aufklappen und kopieren. Paste: Einfügen als Python-Notebook z.B. auf: JupyterLite oder JupyterLab oder Play: Ausführen. Lieber mit eigenem SymPy und offline? Es gibt z.B. Anaconda und Miniconda. Statt SymPy lieber anderes CAS? Auswahl hier.Lösung
2. (x,y)-Komponenten
Lösung
SymPy
Source Code
# -*- coding: utf-8 -*-
from sympy.physics.units import *
from sympy import *
# Units:
(mm, cm) = ( m/1000, m/100 )
Newton = kg*m/s**2
kN = 10**3*Newton
Pa = Newton/m**2
MPa = 10**6*Pa
GPa = 10**9*Pa
deg = pi/180
half = S(1)/2
# Rounding:
import decimal
from decimal import Decimal as DX
from copy import deepcopy
def iso_round(obj, pv,
rounding=decimal.ROUND_HALF_EVEN):
import sympy
"""
Rounding acc. to DIN EN ISO 80000-1:2013-08
place value = Rundestellenwert
"""
assert pv in set([
# place value # round to:
"1", # round to integer
"0.1", # 1st digit after decimal
"0.01", # 2nd
"0.001", # 3rd
"0.0001", # 4th
"0.00001", # 5th
"0.000001", # 6th
"0.0000001", # 7th
"0.00000001", # 8th
"0.000000001", # 9th
"0.0000000001", # 10th
])
objc = deepcopy(obj)
try:
tmp = DX(str(float(objc)))
objc = tmp.quantize(DX(pv), rounding=rounding)
except:
for i in range(len(objc)):
tmp = DX(str(float(objc[i])))
objc[i] = tmp.quantize(DX(pv), rounding=rounding)
return objc
# ---
pprint("\nPart 1:")
(vx, vy) = ( -2, 3 )
v = Matrix((vx, vy))
r = sqrt(vx*vx + vy*vy)
pprint("v:")
tmp = r
tmp = iso_round(tmp,"0.1")
pprint(tmp)
pprint("\nφ / °:")
phi = 2*atan( vy/(r + vx) )
tmp = phi / deg
tmp = iso_round(tmp,"0.1")
pprint(tmp)
# Check:
tmp = r*cos(phi)
tmp = tmp.simplify()
assert(tmp==vx)
tmp = r*sin(phi)
tmp = tmp.simplify()
assert(tmp==vy)
pprint("\nPart 2:")
(v, p) = (3.5, 120*deg)
c, s = cos(p), sin(p)
vx, vy = v*c, v*s
tmp = Matrix([vx, vy])
tmp = iso_round(tmp,"0.01")
pprint(tmp)