9.3.2. Rotating vectors#
For this second example, let’s apply this same transform to a vector of 10 units toward the x-axis (10, 0, 0) as shown in Fig. 9.11.
Fig. 9.11 Rotating a vector in respect to the global reference frame.#
The same equation applies:
Although vector \(\vec{v}_\text{initial}\) shares the same coordinates as \(p_\text{initial}\) in the previous example, it is written differently (with a 0 instead of a 1 in the fourth coordinate). This is because the fourth element is responsible for translations, and contrary to a point, a vector cannot be translated.
We multiply this vector by the transform to obtain the final vector:
The final coordinates of the vector are (8.66, 5, 0).
9.3.2.1. Application in Kinetics Toolkit#
The transform \(T\) can be created using:
import kineticstoolkit.lab as ktk
T = ktk.geometry.create_transform_series(
angles=[30],
degrees=True,
seq="z", # Which means a rotation around the z axis
)
T
array([[[ 0.8660254, -0.5 , 0. , 0. ],
[ 0.5 , 0.8660254, 0. , 0. ],
[ 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 1. ]]])
The rotated vector is:
ktk.geometry.matmul(T, [[10, 0, 0, 1]])
array([[8.66025404, 5. , 0. , 1. ]])
9.3.2.2. Direct transformation in Kinetics Toolkit#
We can also rotate the vector directly using ktk.geometry.rotate:
ktk.geometry.rotate([[10, 0, 0, 0]], seq="z", angles=[30], degrees=True)
array([[8.66025404, 5. , 0. , 0. ]])