M.2.M

Gegeben

../../../_images/M.2.M.png

Gegeben:

  • das \(\left(x, y, z\right)\)-System

  • der rote Vektor \(\boldsymbol v\) über seine \((x, y, z)\)-Komponenten:

    \[\begin{split}\begin{bmatrix} v_x \\ v_y \\ v_z \end{bmatrix} &= \begin{bmatrix} -3 \\ 4 \\ 0 \end{bmatrix}\end{split}\]
  • der Vektor \(\boldsymbol v'\), der relativ zu \(\boldsymbol v\) gedreht ist um die grüne \(y\)-Achse

  • der Drehwinkel \(\alpha\), positiv gezählt entsprechend der Schraubenregel:

    \[\alpha = 210^\circ\]

Berechnen Sie die Komponenten des gedrehten Vektors \(\boldsymbol v'\), und zwar gerundet auf Rundestellenwert \(0{,}001\). Füllen Sie die Spaltenmatrix mit den 3 Komponenten:

\[\begin{split}\begin{bmatrix} v'_x \\ v'_y \\ v'_z \end{bmatrix} \stackrel{\scriptscriptstyle{0{,}001}}{\approx} \begin{bmatrix} \ldots \\ \ldots \\ \ldots \end{bmatrix}\end{split}\]

Lösung

Aktive Transformation:

\begin{align*} \begin{bmatrix} v'_{x} \\ v'_{y} \\ v'_{z} \\ \end{bmatrix} &= \begin{bmatrix} c_\alpha & 0 & s_\alpha\\ 0 & 1 & 0 \\ -s_\alpha & 0 & c_\alpha \\ \end{bmatrix} \begin{bmatrix} v_x \\ v_y \\ v_z \\ \end{bmatrix} \\ & \stackrel{\scriptscriptstyle{0{,}001}}{\approx} \begin{bmatrix} 2{,}598 \\ 4 \\ -1{,}5 \end{bmatrix} \end{align*}

SymPy

Source Code eines Programms dazu:

from sympy.physics.units import kg, m, s
from sympy import pi, S, Matrix, cos, sin, pprint, var

# Units:
N         =  kg*m/s**2
k, M, G   =  10**3, 10**6, 10**9
kN        =  k*N
Pa        =  N/m**2
MPa, GPa  =  M*Pa, G*Pa
deg       =  pi/180
half      =  S(1)/2

# Rounding:
def iso_round(x, pv):
    try:
        x = float(x)
        tmp = round(x, pv)
    except TypeError:
        from functools import partial
        func = partial(round, ndigits = pv)
        tmp = x.applyfunc(func)
    return tmp

# Header ends here.

# https://en.wikipedia.org/wiki/Rotation_formalisms_in_three_dimensions
# https://en.wikipedia.org/wiki/Rotation_matrix
# https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula

def get_R(axis, angle):
    c, s = cos(angle), sin(angle)
    if axis == "z":
        R = Matrix([
        [ c, s, 0],
        [-s, c, 0],
        [ 0, 0, 1],
        ])
    elif axis == "x":
        R = Matrix([
        [ 1, 0, 0],
        [ 0, c, s],
        [ 0,-s, c],
        ])
    elif axis == "y":
        R = Matrix([
        [ c, 0,-s],
        [ 0, 1, 0],
        [ s, 0, c],
        ])
    else:
        axis /= axis.norm()
        e1, e2, e3 = axis[0], axis[1], axis[2]
        K = Matrix([
            [   0, -e3,  e2],
            [  e3,   0, -e1],
            [ -e2,  e1,   0],
            ])
        R = eye(3) - s*K + (1 - c)*K*K
    return R

pprint("\nInput:")

pprint("\n(x,y,z)-Comp. of Vector:")
v = Matrix([-3,4,0])
pprint(v)

pprint("\nRotation angle:")
angle = -210 *deg
pprint(angle)

pprint("\nRotation axis:")
axis = "y"
# axis = Matrix([0,4,0])
pprint(axis)

pprint("\nOutput:")

pprint("\nRotation-Matrix:")
R = get_R(axis, angle)
pprint(R)

pprint("\n(x̄,ȳ,z̄)-Comp. of Vector:")
v̄ = R*v
tmp = v̄
tmp = iso_round(tmp, 3)
pprint(tmp)

Programm ausführen? Dazu:

  1. Copy: Source Code in die Zwischenablage kopieren.

  2. Paste: Source Code ins Eingabefeld hinter [ ]: einfügen.

  3. Play: Knopf ▶ drücken.