# Frame of reference¶

Marcos Duarte, Renato Naville Watanabe
Laboratory of Biomechanics and Motor Control
Federal University of ABC, Brazil

Motion (a change of position in space with respect to time) is not an absolute concept; a reference is needed to describe the motion of the object in relation to this reference. Likewise, the state of such reference cannot be absolute in space and so motion is relative.
A frame of reference is the place with respect to we choose to describe the motion of an object. In this reference frame, we define a coordinate system (a set of axes) within which we measure the motion of an object (but frame of reference and coordinate system are often used interchangeably).

Often, the choice of reference frame and coordinate system is made by convenience. However, there is an important distinction between reference frames when we deal with the dynamics of motion, where we are interested to understand the forces related to the motion of the object. In dynamics, we refer to inertial frame of reference (a.k.a., Galilean reference frame) when the Newton's laws of motion in their simple form are valid in this frame and to non-inertial frame of reference when the Newton's laws in their simple form are not valid (in such reference frame, fictitious accelerations/forces appear). An inertial reference frame is at rest or moves at constant speed (because there is no absolute rest!), whereas a non-inertial reference frame is under acceleration (with respect to an inertial reference frame).

The concept of frame of reference has changed drastically since Aristotle, Galileo, Newton, and Einstein. To read more about that and its philosophical implications, see Space and Time: Inertial Frames.

## Frame of reference for human motion analysis¶

In anatomy, we use a simplified reference frame composed by perpendicular planes to provide a standard reference for qualitatively describing the structures and movements of the human body, as shown in the next figure.

## Cartesian coordinate system¶

As we perceive the surrounding space as three-dimensional, a convenient coordinate system is the Cartesian coordinate system in the Euclidean space with three orthogonal axes as shown below. The axes directions are commonly defined by the right-hand rule and attributed the letters X, Y, Z. The orthogonality of the Cartesian coordinate system is convenient for its use in classical mechanics, most of the times the structure of space is assumed having the Euclidean geometry and as consequence, the motion in different directions are independent of each other. Figure. A point in three-dimensional Euclidean space described in a Cartesian coordinate system.

### Standardizations in movement analysis¶

The concept of reference frame in Biomechanics and motor control is very important and central to the understanding of human motion. For example, do we see, plan and control the movement of our hand with respect to reference frames within our body or in the environment we move? Or a combination of both?
The figure below, although derived for a robotic system, illustrates well the concept that we might have to deal with multiple coordinate systems. Figure. Multiple coordinate systems for use in robots (figure from Corke (2017)).

For three-dimensional motion analysis in Biomechanics, we may use several different references frames for convenience and refer to them as global, laboratory, local, anatomical, or technical reference frames or coordinate systems (we will study this later).
There has been proposed different standardizations on how to define frame of references for the main segments and joints of the human body. For instance, the International Society of Biomechanics has a page listing standardization proposals by its standardization committee and subcommittees:

In :
from IPython.display import IFrame
IFrame('https://isbweb.org/activities/standards', width='100%', height=400)

Out:

Another initiative for the standardization of references frames is from the Virtual Animation of the Kinematics of the Human for Industrial, Educational and Research Purposes (VAKHUM) project.

## Determination of a coordinate system¶

In Biomechanics, we may use different coordinate systems for convenience and refer to them as global, laboratory, local, anatomical, or technical reference frames or coordinate systems. For example, in a standard gait analysis, we define a global or laboratory coordinate system and a different coordinate system for each segment of the body to be able to describe the motion of a segment in relation to anatomical axes of another segment. To define this anatomical coordinate system, we need to place markers on anatomical landmarks on each segment. We also may use other markers (technical markers) on the segment to improve the motion analysis and then we will also have to define a technical coordinate system for each segment.

As we perceive the surrounding space as three-dimensional, a convenient coordinate system to use is the Cartesian coordinate system with three orthogonal axes in the Euclidean space. From linear algebra, a set of unit linearly independent vectors (orthogonal in the Euclidean space and each with norm (length) equals to one) that can represent any vector via linear combination is called a basis (or orthonormal basis). The figure below shows a point and its position vector in the Cartesian coordinate system and the corresponding versors (unit vectors) of the basis for this coordinate system. See the notebook Scalar and vector for a description on vectors. Figure. Representation of a point **P** and its position vector $\overrightarrow{\mathbf{r}}$ in a Cartesian coordinate system. The versors $\hat{\mathbf{i}}, \hat{\mathbf{j}}, \hat{\mathbf{k}}$ form a basis for this coordinate system and are usually represented in the color sequence RGB (red, green, blue) for easier visualization.

One can see that the versors of the basis shown in the figure above have the following coordinates in the Cartesian coordinate system:

\begin{equation} \hat{\mathbf{i}} = \begin{bmatrix}1\\0\\0 \end{bmatrix}, \quad \hat{\mathbf{j}} = \begin{bmatrix}0\\1\\0 \end{bmatrix}, \quad \hat{\mathbf{k}} = \begin{bmatrix} 0 \\ 0 \\ 1 \end{bmatrix} \end{equation}

Using the notation described in the figure above, the position vector $\overrightarrow{\mathbf{r}}$ (or the point $\overrightarrow{\mathbf{P}}$) can be expressed as:

\begin{equation} \overrightarrow{\mathbf{r}} = x\hat{\mathbf{i}} + y\hat{\mathbf{j}} + z\hat{\mathbf{k}} \end{equation}

### Definition of a basis¶

The mathematical problem of determination of a coordinate system is to find a basis and an origin for it (a basis is only a set of vectors, with no origin). There are different methods to calculate a basis given a set of points (coordinates), for example, one can use the scalar product or the cross product for this problem.

### Using the cross product¶

Let's now define a basis using a common method in motion analysis (employing the cross product):
Given the coordinates of three noncollinear points in 3D space (points that do not all lie on the same line), $\overrightarrow{\mathbf{m}}_1, \overrightarrow{\mathbf{m}}_2, \overrightarrow{\mathbf{m}}_3$, which would represent the positions of markers captured from a motion analysis session, a basis can be found following these steps:

1. First axis, $\overrightarrow{\mathbf{v}}_1$, the vector $\overrightarrow{\mathbf{m}}_2-\overrightarrow{\mathbf{m}}_1$ (or any other vector difference);
1. Second axis, $\overrightarrow{\mathbf{v}}_2$, the cross or vector product between the vectors $\overrightarrow{\mathbf{v}}_1$ and $\overrightarrow{\mathbf{m}}_3-\overrightarrow{\mathbf{m}}_1$ (or $\overrightarrow{\mathbf{m}}_3-\overrightarrow{\mathbf{m}}_2$);
1. Third axis, $\overrightarrow{\mathbf{v}}_3$, the cross product between the vectors $\overrightarrow{\mathbf{v}}_1$ and $\overrightarrow{\mathbf{v}}_2$.
1. Make all vectors to have norm 1 dividing each vector by its norm.

The positions of the points used to construct a coordinate system have, by definition, to be specified in relation to an already existing coordinate system. In motion analysis, this coordinate system is the coordinate system from the motion capture system and it is established in the calibration phase. In this phase, the positions of markers placed on an object with perpendicular axes and known distances between the markers are captured and used as the reference (laboratory) coordinate system.

For example, given the positions $\overrightarrow{\mathbf{m}}_1 = [1,2,5], \overrightarrow{\mathbf{m}}_2 = [2,3,3], \overrightarrow{\mathbf{m}}_3 = [4,0,2]$, a basis can be found with:

In :
import numpy as np

m1 = np.array([1, 2, 5])
m2 = np.array([2, 3, 3])
m3 = np.array([4, 0, 2])

v1 = m2 - m1                # first axis
v2 = np.cross(v1, m3 - m1)  # second axis
v3 = np.cross(v1, v2)       # third axis

# Vector normalization
e1 = v1/np.linalg.norm(v1)
e2 = v2/np.linalg.norm(v2)
e3 = v3/np.linalg.norm(v3)

print('Versors:', '\ne1 =', e1, '\ne2 =', e2, '\ne3 =', e3)

print('\nNorm of each versor:',
'\n||e1|| =', np.linalg.norm(e1),
'\n||e2|| =', np.linalg.norm(e2),
'\n||e3|| =', np.linalg.norm(e3))

print('\nTest of orthogonality (cross product between versors):',
'\ne1 x e2:', np.linalg.norm(np.cross(e1, e2)),
'\ne1 x e3:', np.linalg.norm(np.cross(e1, e3)),
'\ne2 x e3:', np.linalg.norm(np.cross(e2, e3)))

Versors:
e1 = [ 0.40824829  0.40824829 -0.81649658]
e2 = [-0.76834982 -0.32929278 -0.5488213 ]
e3 = [-0.49292179  0.85141036  0.17924429]

Norm of each versor:
||e1|| = 1.0
||e2|| = 1.0
||e3|| = 1.0

Test of orthogonality (cross product between versors):
e1 x e2: 1.0
e1 x e3: 1.0000000000000002
e2 x e3: 0.9999999999999999


To define a coordinate system using the calculated basis, we also need to define an origin. In principle, we could use any point as origin, but if the calculated coordinate system should follow anatomical conventions, e.g., the coordinate system origin should be at a joint center, we will have to calculate the basis and origin according to standards used in motion analysis as discussed before.

If the coordinate system is a technical basis and not anatomic-based, a common procedure in motion analysis is to define the origin for the coordinate system as the centroid (average) position among the markers at the reference frame. Using the average position across markers potentially reduces the effect of noise (for example, from soft tissue artifact) on the calculation.

For the markers in the example above, the origin of the coordinate system will be:

In :
origin = np.mean((m1, m2, m3), axis=0)
print('Origin: ', origin)

Origin:  [2.33333333 1.66666667 3.33333333]


Let's plot the coordinate system and the basis using the custom Python function CCS.py:

In :
import sys
sys.path.insert(1, r'./../functions')  # add to pythonpath
from CCS import CCS

In :
markers = np.vstack((m1, m2, m3))
basis = np.vstack((e1, e2, e3))


In :
%matplotlib notebook

CCS(xyz=[], Oijk=origin, ijk=basis, point=markers, vector=True); ### Gram–Schmidt process¶

Another classical procedure in mathematics, employing the scalar product, is known as the Gram–Schmidt process. See the notebook Scalar and Vector for a demonstration of the Gram–Schmidt process and how to implement it in Python.

The Gram–Schmidt process is a method for orthonormalizing (orthogonal unit versors) a set of vectors using the scalar product. The Gram–Schmidt process works for any number of vectors.

For example, given three vectors, $\overrightarrow{\mathbf{a}}, \overrightarrow{\mathbf{b}}, \overrightarrow{\mathbf{c}}$, in the 3D space, a basis $\{\hat{e}_a, \hat{e}_b, \hat{e}_c\}$ can be found using the Gram–Schmidt process by:

The first versor is in the $\overrightarrow{\mathbf{a}}$ direction (or in the direction of any of the other vectors):

\begin{equation} \hat{e}_a = \frac{\overrightarrow{\mathbf{a}}}{||\overrightarrow{\mathbf{a}}||} \end{equation}

The second versor, orthogonal to $\hat{e}_a$, can be found considering we can express vector $\overrightarrow{\mathbf{b}}$ in terms of the $\hat{e}_a$ direction as:

$$\overrightarrow{\mathbf{b}} = \overrightarrow{\mathbf{b}}^\| + \overrightarrow{\mathbf{b}}^\bot$$

Then:

$$\overrightarrow{\mathbf{b}}^\bot = \overrightarrow{\mathbf{b}} - \overrightarrow{\mathbf{b}}^\| = \overrightarrow{\mathbf{b}} - (\overrightarrow{\mathbf{b}} \cdot \hat{e}_a ) \hat{e}_a$$

Finally:

$$\hat{e}_b = \frac{\overrightarrow{\mathbf{b}}^\bot}{||\overrightarrow{\mathbf{b}}^\bot||}$$

The third versor, orthogonal to $\{\hat{e}_a, \hat{e}_b\}$, can be found expressing the vector $\overrightarrow{\mathbf{C}}$ in terms of $\hat{e}_a$ and $\hat{e}_b$ directions as:

$$\overrightarrow{\mathbf{c}} = \overrightarrow{\mathbf{c}}^\| + \overrightarrow{\mathbf{c}}^\bot$$

Then:

$$\overrightarrow{\mathbf{c}}^\bot = \overrightarrow{\mathbf{c}} - \overrightarrow{\mathbf{c}}^\|$$

Where:

$$\overrightarrow{\mathbf{c}}^\| = (\overrightarrow{\mathbf{c}} \cdot \hat{e}_a ) \hat{e}_a + (\overrightarrow{\mathbf{c}} \cdot \hat{e}_b ) \hat{e}_b$$

Finally:

$$\hat{e}_c = \frac{\overrightarrow{\mathbf{c}}^\bot}{||\overrightarrow{\mathbf{c}}^\bot||}$$

Let's implement the Gram–Schmidt process in Python.

For example, consider the positions (vectors) $\overrightarrow{\mathbf{a}} = [1,2,0], \overrightarrow{\mathbf{b}} = [0,1,3], \overrightarrow{\mathbf{c}} = [1,0,1]$:

The first versor is:

In :
ea = m1/np.linalg.norm(m1)
print(ea)

[0.18257419 0.36514837 0.91287093]


The second versor is:

In :
eb = m2 - np.dot(m2, ea)*ea
eb = eb/np.linalg.norm(eb)
print(eb)

[ 0.59020849  0.70186955 -0.39878952]


And the third version is:

In :
ec = m3 - np.dot(m3, ea)*ea - np.dot(m3, eb)*eb
ec = ec/np.linalg.norm(ec)
print(ec)

[ 0.78633365 -0.61159284  0.08737041]


Let's check the orthonormality between these versors:

In :
print(' Versors:', '\nea =', ea, '\neb =', eb, '\nec =', ec)

print('\n Norm of each versor:',
'\n ||ea|| =', np.linalg.norm(ea),
'\n ||eb|| =', np.linalg.norm(eb),
'\n ||ec|| =', np.linalg.norm(ec))

print('\n Test of orthogonality (scalar product between versors):',
'\n ea . eb:', np.dot(ea, eb),
'\n eb . ec:', np.dot(eb, ec),
'\n ec . ea:', np.dot(ec, ea))

 Versors:
ea = [0.18257419 0.36514837 0.91287093]
eb = [ 0.59020849  0.70186955 -0.39878952]
ec = [ 0.78633365 -0.61159284  0.08737041]

Norm of each versor:
||ea|| = 1.0
||eb|| = 1.0
||ec|| = 1.0

Test of orthogonality (scalar product between versors):
ea . eb: -3.3306690738754696e-16
eb . ec: 6.245004513516506e-17
ec . ea: 8.326672684688674e-17


## Polar and spherical coordinate systems¶

When studying circular motion in two or three dimensions, the use of a polar (for 2D) or spherical (for 3D) coordinate system can be more convenient than the Cartesian coordinate system.

### Polar coordinate system¶

In the polar coordinate system, a point in a plane is described by its distance $r$ to the origin (the ray from the origin to this point is the polar axis) and the angle $\theta$ (measured counterclockwise) between the polar axis and an axis of the coordinate system as shown next.

The relation of the coordinates in the Cartesian and polar coordinate systems is:

$$\begin{array}{l l} x = r\cos\theta \\ y = r\sin\theta \\ r = \sqrt{x^2 + y^2} \end{array}$$

### Spherical coordinate system¶

The spherical coordinate system can be seen as an extension of the polar coordinate system to three dimensions where an orthogonal axis is added and a second angle is used to describe the point with respect to this third axis as shown next.

The relation of the coordinates in the Cartesian and spherical coordinate systems is:

$$\begin{array}{l l} x = r\sin\theta\cos\phi \\ y = r\sin\theta\sin\phi \\ z = r\cos\theta \\ r = \sqrt{x^2 + y^2 + z^2} \end{array}$$

## Generalized coordinates¶

In mechanics, generalized coordinates are a set of coordinates that describes the configuration of a system. Generalized coordinates are usually selected for convenience (e.g., simplifies the resolution of the problem) or to provide the minimum number of coordinates to describe the configuration of a system.

For instance, generalized coordinates are used to describe the motion of a system with multiple links where instead of using Cartesian coordinates, it's more convenient to use the angles between links as coordinates.

## Problems¶

1. Right now, how fast are you moving? In your answer, consider your motion in relation to Earth and in relation to Sun.

2. Go to the website http://www.wisc-online.com/Objects/ViewObject.aspx?ID=AP15305 and complete the interactive lesson to learn about the anatomical terminology to describe relative position in the human body.

3. To learn more about Cartesian coordinate systems go to the website http://www.mathsisfun.com/data/cartesian-coordinates.html, study the material, and answer the 10 questions at the end.

4. Given the points in the 3D space, $m1 = [2,2,0], m2 = [0,1,1], m3 = [1,2,0]$, find an orthonormal basis.

5. Determine if the following points form a basis in the 3D space, $m1 = [2,2,0], m2 = [1,1,1], m3 = [1,1,0]$.

6. Derive expressions for the three axes of the pelvic basis considering the convention of the Virtual Animation of the Kinematics of the Human for Industrial, Educational and Research Purposes (VAKHUM) project (use RASIS, LASIS, RPSIS, and LPSIS as names for the pelvic anatomical landmarks and indicate the expression for each axis).

7. Determine the basis for the pelvis following the convention of the Virtual Animation of the Kinematics of the Human for Industrial, Educational and Research Purposes (VAKHUM) project for the following anatomical landmark positions (units in meters): $RASIS=[0.5,0.8,0.4], LASIS=[0.55,0.78,0.1], RPSIS=[0.3,0.85,0.2], LPSIS=[0.29,0.78,0.3]$.