9.2.3.5. Exercise: A fixed point in a moving coordinate system#
In Fig. 9.6, the position of the elbow in the arm coordinate system is \((0, -0.5, 0)\).
Using Kinetics Toolkit’s geometry module, express the position of the elbow in global coordinates for a movement of shoulder flexion of 0°, 5°, 10° and 15°.
a) Do this exercise by creating the corresponding homogeneous transform using ktk.geometry.create_transforms, then by multiplying this transform by the point coordinates using ktk.geometry.matmul.
Show code cell content
import kineticstoolkit.lab as ktk
import numpy as np
p_elbow_ref_arm = np.array([[0.0, -0.5, 0.0, 1.0]])
T_arm = ktk.geometry.create_transforms(
angles=[
np.deg2rad(0.0),
np.deg2rad(5.0),
np.deg2rad(10.0),
np.deg2rad(15.0),
],
seq="z",
)
ktk.geometry.matmul(T_arm, p_elbow_ref_arm)
array([[ 0. , -0.5 , 0. , 1. ],
[ 0.04357787, -0.49809735, 0. , 1. ],
[ 0.08682409, -0.49240388, 0. , 1. ],
[ 0.12940952, -0.48296291, 0. , 1. ]])
b) Do this exercise using the ktk.geometry.rotate and ktk.geometry.translate function.
Show code cell content
p_elbow_ref_arm = np.array([[0.0, -0.5, 0.0, 1.0]])
ktk.geometry.rotate(
p_elbow_ref_arm,
angles=[
np.deg2rad(0.0),
np.deg2rad(5.0),
np.deg2rad(10.0),
np.deg2rad(15.0),
],
seq="z",
)
array([[ 0. , -0.5 , 0. , 1. ],
[ 0.04357787, -0.49809735, 0. , 1. ],
[ 0.08682409, -0.49240388, 0. , 1. ],
[ 0.12940952, -0.48296291, 0. , 1. ]])