5.12. Multidimensional arrays#
In the previous section, we learned how to access one element of a one-dimensional array using indexing, and how to access multiple elements of a one-dimensional array using slicing and filtering. We will now generalize this to multidimensional arrays. Throughout this tutorial, we will use these two sample arrays:
Sample array #1: Trajectory of a marker during three samples
The position of a marker is expressed by three coordinates (x, y, z), usually followed by a constant value of 1. A trajectory is expressed as a series of positions. Therefore, we express the trajectory of a marker using:
Axis 0: sample
Axis 1: coordinate

import numpy as np
position = np.array(
[
[0.497, 0.973, 0.010, 1.0],
[0.528, 0.973, 0.017, 1.0],
[0.589, 0.970, 0.025, 1.0],
]
)
position
array([[0.497, 0.973, 0.01 , 1. ],
[0.528, 0.973, 0.017, 1. ],
[0.589, 0.97 , 0.025, 1. ]])
Sample array #2: Series of segment orientation during two samples
The orientation of a segment is expressed as a 4x4 homogeneous matrix. Therefore, we can express a series of orientations using:
Axis 0: sample
Axis 1: line of the homogeneous transform matrix
Axis 2: column of the homogeneous transform matrix

orientation = np.array(
[
[
[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0],
],
[
[1.0, 0.000, 0.000, 0.0],
[0.0, 0.999, -0.017, 0.0],
[0.0, 0.017, 0.999, 0.0],
[0.0, 0.000, 0.000, 1.0],
],
]
)
orientation
array([[[ 1. , 0. , 0. , 0. ],
[ 0. , 1. , 0. , 0. ],
[ 0. , 0. , 1. , 0. ],
[ 0. , 0. , 0. , 1. ]],
[[ 1. , 0. , 0. , 0. ],
[ 0. , 0.999, -0.017, 0. ],
[ 0. , 0.017, 0.999, 0. ],
[ 0. , 0. , 0. , 1. ]]])