"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Python setup"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2020-10-11T03:44:08.293508Z",
"start_time": "2020-10-11T03:44:07.779017Z"
}
},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'sympy'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mnumpy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0msympy\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0msympy\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvector\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mCoordSys3D\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mmatplotlib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0msym\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minit_printing\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'sympy'"
]
}
],
"source": [
"import numpy as np\n",
"import sympy as sym\n",
"from sympy.vector import CoordSys3D\n",
"import matplotlib.pyplot as plt\n",
"sym.init_printing()\n",
"from sympy.plotting import plot_parametric\n",
"from sympy.physics.mechanics import ReferenceFrame, Vector, dot\n",
"from matplotlib.patches import FancyArrowPatch\n",
"plt.rcParams.update({'figure.figsize':(8, 5), 'lines.linewidth':2})"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Cartesian coordinate system\n",
"\n",
"As we perceive the surrounding space as three-dimensional, a convenient coordinate system is the [Cartesian coordinate system](http://en.wikipedia.org/wiki/Cartesian_coordinate_system) in the [Euclidean space](http://en.wikipedia.org/wiki/Euclidean_space) with three orthogonal axes as shown below. The axes directions are commonly defined by the [right-hand rule](http://en.wikipedia.org/wiki/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](http://en.wikipedia.org/wiki/Euclidean_geometry) and as consequence, the motion in different directions are independent of each other. \n",
" \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Determination of a coordinate system\n",
"\n",
"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. \n",
"\n",
"From [linear algebra](http://en.wikipedia.org/wiki/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](http://en.wikipedia.org/wiki/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](http://nbviewer.ipython.org/github/demotu/BMC/blob/master/notebooks/ScalarVector.ipynb) for a description on vectors. \n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"One can see that the versors of the basis shown in the figure above have the following coordinates in the Cartesian coordinate system:\n",
" \n",
"\n",
"\\begin{equation}\n",
"\\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}\n",
"\\label{eq_1}\n",
"\\end{equation}\n",
"\n",
"\n",
"Using the notation described in the figure above, the position vector $\\overrightarrow{\\mathbf{r}}$ can be expressed as:\n",
" \n",
"\n",
"\\begin{equation}\n",
"\\overrightarrow{\\mathbf{r}} = x\\hat{\\mathbf{i}} + y\\hat{\\mathbf{j}} + z\\hat{\\mathbf{k}}\n",
"\\label{eq_2}\n",
"\\end{equation}\n",
"\n",
"\n",
"However, to use a fixed basis can lead to very complex expressions."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Path basis"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Consider that we have the position vector of a particle, moving in the path described by the parametric curve $s(t)$, described in a fixed reference frame as:\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\hat{r}}(t) = {x}{\\bf\\hat{i}}+{y}{\\bf\\hat{j}} + {z}{\\bf\\hat{k}}\n",
"\\label{eq_3}\n",
"\\end{equation}\n",
"\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Tangential versor\n",
"\n",
"Often we describe all the kinematic variables in this fixed reference frame. However, it is often useful to define a path basis, attached to some point of interest. In this case, what is usually done is to choose as one of the basis vector a unitary vector in the direction of the velocity of the particle. Defining this vector as:\n",
"\n",
"\n",
"\\begin{equation}\n",
"{\\bf\\hat{e}_t} = \\frac{{\\bf\\vec{v}}}{\\Vert{\\bf\\vec{v}}\\Vert}\n",
"\\label{eq_4}\n",
"\\end{equation}\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"variables": {
"\\bf\\vec{C": "
SyntaxError: unexpected character after line continuation character (, line 1)
\n",
"\\bf\\vec{v": "
SyntaxError: unexpected character after line continuation character (, line 1)
\n"
}
},
"source": [
"### Normal versor\n",
"\n",
"For the second vector of the basis, we define first a vector of curvature of the path (the meaning of this curvature vector will be seeing in another notebook):\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\vec{C}} = \\frac{d{\\bf\\hat{e}_t}}{ds}\n",
"\\label{eq_5}\n",
"\\end{equation}\n",
"\n",
"\n",
"Note that $\\bf\\hat{e}_t$ is a function of the path $s(t)$. So, by the chain rule:\n",
" \n",
"\n",
"\\begin{equation}\n",
"\\frac{d{\\bf\\hat{e}_t}}{dt} = \\frac{d{\\bf\\hat{e}_t}}{ds}\\frac{ds}{dt} \\longrightarrow \\frac{d{\\bf\\hat{e}_t}}{ds} = \\frac{\\frac{d{\\bf\\hat{e}_t}}{dt}}{\\frac{ds}{dt}} \\longrightarrow {\\bf\\vec{C}} = \\frac{\\frac{d{\\bf\\hat{e}_t}}{dt}}{\\frac{ds}{dt}}\\longrightarrow {\\bf\\vec{C}} = \\frac{\\frac{d{\\bf\\hat{e}_t}}{dt}}{\\Vert{\\bf\\vec{v}}\\Vert}\n",
"\\label{eq_6}\n",
"\\end{equation}\n",
"\n",
"\n",
"Now we can define the second vector of the basis, ${\\bf\\hat{e}_n}$:\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\hat{e}_n} = \\frac{{\\bf\\vec{C}}}{\\Vert{\\bf\\vec{C}}\\Vert}\n",
"\\label{eq_7}\n",
"\\end{equation}\n",
"\n",
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"### Binormal versor\n",
"\n",
"The third vector of the basis is obtained by the cross product between ${\\bf\\hat{e}_n}$ and ${\\bf\\hat{e}_t}$:\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\hat{e}_b} = {\\bf\\hat{e}_t} \\times {\\bf\\hat{e}_n}\n",
"\\label{eq_8}\n",
"\\end{equation}\n",
"\n",
"\n",
"Note that the vectors ${\\bf\\hat{e}_t}$ , ${\\bf\\hat{e}_n}$ and ${\\bf\\hat{e}_b}$ vary together with the particle movement. This basis is also called as **Frenet-Serret frame**."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Velocity and Acceleration in a path frame"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"variables": {
"\\bf\\hat{e}_t": "
SyntaxError: unexpected character after line continuation character (, line 1)
SyntaxError: unexpected character after line continuation character (, line 1)
\n",
"d\\bf\\vec{v": "
SyntaxError: unexpected character after line continuation character (, line 1)
\n"
}
},
"source": [
"### Velocity \n",
"\n",
"Given the expression of $r(t)$ in a fixed frame we can write the velocity ${\\bf\\vec{v}(t)}$ as a function of the fixed frame of reference ${\\bf\\hat{i}}$, ${\\bf\\hat{j}}$ and ${\\bf\\hat{k}}$ (see http://nbviewer.jupyter.org/github/BMClab/bmc/blob/master/notebooks/KinematicsParticle.ipynb)).\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\vec{v}}(t) = \\dot{x}{\\bf\\hat{i}}+\\dot{y}{\\bf\\hat{j}}+\\dot{z}{\\bf\\hat{k}}\n",
"\\label{eq_9}\n",
"\\end{equation}\n",
"\n",
"\n",
"However, this can lead to very complex functions. So it is useful to use the basis find previously ${\\bf\\hat{e}_t}$, ${\\bf\\hat{e}_n}$ and ${\\bf\\hat{e}_b}$.\n",
"\n",
"The velocity ${\\bf\\vec{v}}$ of the particle is, by the definition of ${\\bf\\hat{e}_t}$, in the direction of ${\\bf\\hat{e}_t}$:\n",
" \n",
"\n",
"\\begin{equation}\n",
"{\\bf\\vec{v}}={\\Vert\\bf\\vec{v}\\Vert}.{\\bf\\hat{e}_t}\n",
"\\label{eq_10}\n",
"\\end{equation}\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
},
"variables": {
"\\bf\\hat{e}_t": "
SyntaxError: unexpected character after line continuation character (, line 1)