fix minor typos in session 7

pull/14/head
Kenneth C. Kleissl 2020-03-03 00:28:06 +01:00
parent 7bb908b020
commit 77a97d44ed
2 changed files with 20 additions and 20 deletions

View File

@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# 7. Tranformation functions\n",
"# 7. Transformation functions\n",
"\n",
"Coordinate transformations can be performed by matrix operations. Some common ones are:\n",
"\n",
@ -74,7 +74,7 @@
"* In the **scaling matrix** $C_x$ and $C_y$ denote the scaling in the $x$- and $y$-direction, respectively. \n",
"\n",
"\n",
"* The **mirroring matrix** has no inputs and can bee seen as a boolean operation. It can be done in exactly one way or not done at all. \n",
"* The **mirroring matrix** has no inputs and simply flips the sign for the directions to be mirrored. \n",
"\n",
"See more here: https://upload.wikimedia.org/wikipedia/commons/2/2c/2D_affine_transformation_matrix.svg"
]
@ -86,13 +86,13 @@
"## Vectorization in `numpy`\n",
"`numpy` can perform calculation in a vectorized manner meaning that vector and matrix operations can be done on entire arrays at a time as opposed to value by value. \n",
"\n",
">**Vectorization can eliminate the use of for loops in many scenarios**\n",
">**Vectorization can eliminate the use of for-loops in many scenarios**\n",
"> \n",
">This makes the code easier to read and write. And as an added bonus, vectorized calculations are also much faster than their looping counterparts.\n",
"\n",
"For the equations above, we can utilize vectorization by using a arrays (or lists) of values for $x$ and $y$ instead of single values. That implies that $1$ also must be an array of ones with the same size.\n",
"For the equations above, we can utilize vectorization by using an arrays of values for $x$ and $y$ instead of single values. That implies that $1$ also must be an array of ones with the same size.\n",
"\n",
"Thus, each vector $[x, y, 1]^T$ on the right hand side of the equations is actually an **array of arrays.**\n",
"Thus, each vector $[x, y, 1]^T$ on the right hand side of the equations are actually an **array of arrays.**\n",
"\n",
"The resulting vector $[x_{\\text{transformed}}, y_{\\text{transformed}}, 1]^T$ is of course also an **array or arrays.**\n",
"\n",
@ -274,7 +274,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Unpacking values for the tranformation examples\n",
"### Unpacking values for the transformation examples\n",
"The resulting array of arrays will have the following code structure\n",
"\n",
"~~~python \n",
@ -364,7 +364,7 @@
}
],
"source": [
"# Create 1x5 vector of ones (1D array)\n",
"# Create 5x1 vector of ones (1D array)\n",
"np.ones(5)"
]
},
@ -398,7 +398,7 @@
"metadata": {},
"source": [
"# Exercise 1\n",
"Write a function that implements rotation of a array of coordinates `x` and `y`. The angle of rotation in clockwise direction should be an input parameter with default value of 90 degrees. The function should return the rotated coordinates `xr` and `yr`.\n",
"Write a function that implements rotation of an array of coordinates `x` and `y`. The angle of rotation in clockwise direction should be an input parameter with default value of 90 degrees. The function should return the rotated coordinates `xr` and `yr`.\n",
"\n",
"Test the function with these arrays.\n",
"\n",
@ -448,7 +448,7 @@
"\n",
"Since the given coordinates in Exercise 1 are symmetric about the $y$-axis, the mirrored coordinates will lie on top of the original ones. Try to test it by plotting.\n",
"\n",
"You can quickly make a more visible test by moving all the $x$-coordinates, say 20 units to the right. Since we are using `numpy` this can be done by simply adding 20 to the array itself `x + 20`. This is a simple example of vectorization."
"You can quickly make a more visible test by moving all the $x$-coordinates, say 20 units to the right. Since we are using `numpy` this can be done by simply adding 20 to the array itself `x + 20`. This is refered to as Broadcasting."
]
},
{
@ -463,7 +463,7 @@
"```python\n",
"def transform(x, y, rotation=0, scaling=(1, 1), translation=(0, 0), mirroring=False):\n",
" '''\n",
" Perform a combined coordinate transformation according to given inputs. If no inputs are given, returns the unchanged coordinates.\n",
" Perform a combined coordinate transformation according to given inputs. If no inputs are given, return the unchanged coordinates.\n",
"\n",
" Args:\n",
" x (array) : x-values to transform.\n",
@ -488,7 +488,7 @@
"metadata": {},
"source": [
"# Additional Exercise\n",
"Write a alternative function for translation where the translation input can be given as a distance that the points should move and the corresponding angle from the $x$-axis. This can often be useful instead of the one defined earlier where the distances are given parallel to the $x$- and $y$-axes."
"Write an alternative function for translation where the translation input can be given as a distance that the points should move and the corresponding angle from the $x$-axis. This can often be useful instead of the one defined earlier where the distances are given parallel to the $x$- and $y$-axes."
]
},
{
@ -803,7 +803,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.7.3"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,

File diff suppressed because one or more lines are too long