Update code
This commit is contained in:
parent
91e0ee5752
commit
0d847f19c7
@ -45,7 +45,9 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Linienzug plotten\n",
|
||||
"# plt.plot(...)\n"
|
||||
"plt.figure()\n",
|
||||
"plt.plot(n[0], n[1])\n",
|
||||
"plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -73,11 +75,14 @@
|
||||
"source": [
|
||||
"# angle soll in Grad angegeben werden\n",
|
||||
"def rotation_matrix(angle):\n",
|
||||
" pass\n",
|
||||
" theta = np.deg2rad(angle)\n",
|
||||
" c = np.cos(theta)\n",
|
||||
" s = np.sin(theta)\n",
|
||||
" return np.array([[c, -s], [s, c]])\n",
|
||||
"\n",
|
||||
"# mögliche Tests\n",
|
||||
"# assert(np.allclose(rotation_matrix(90).dot(np.array([1,0])), np.array([0,1])))\n",
|
||||
"# assert(np.allclose(rotation_matrix(-90).dot(np.array([1,0])), np.array([0,-1])))"
|
||||
"assert np.allclose(rotation_matrix(90).dot(np.array([1,0])), np.array([0,1]))\n",
|
||||
"assert np.allclose(rotation_matrix(-90).dot(np.array([1,0])), np.array([0,-1]))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -94,9 +99,11 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# n_rot soll die rotierten Punkte enthalten, n_rot.shape == n.shape\n",
|
||||
"n_rot = ...\n",
|
||||
"n_rot = rotation_matrix(60).dot(n)\n",
|
||||
"\n",
|
||||
"# und erneut plotten..."
|
||||
"plt.figure()\n",
|
||||
"plt.plot(n_rot[0], n_rot[1])\n",
|
||||
"plt.show()\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -123,10 +130,9 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def scale_matrix(sx, sy):\n",
|
||||
" pass\n",
|
||||
" return np.array([[sx, 0], [0, sy]])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# todo test schreiben?"
|
||||
"assert np.allclose(scale_matrix(2, 3).dot(np.array([1,1])), np.array([2,3]))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -142,12 +148,12 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Punkte skalieren\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# und plotten\n",
|
||||
"\n"
|
||||
"scaled = scale_matrix(2, 0.5).dot(n)\n",
|
||||
"plt.figure()\n",
|
||||
"plt.plot(n[0], n[1], label=\"original\")\n",
|
||||
"plt.plot(scaled[0], scaled[1], label=\"scaled\")\n",
|
||||
"plt.legend()\n",
|
||||
"plt.show()\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 1,
|
||||
"id": "00d20df1",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@ -108,7 +108,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 21,
|
||||
"execution_count": null,
|
||||
"id": "6ee1ca50",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@ -121,8 +121,8 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"lenght = sum([np.linalg.norm(f) for f in fahrten])\n",
|
||||
"print(\"Länge der Fahrt:\", lenght)"
|
||||
"length = sum([np.linalg.norm(f) for f in fahrten])\n",
|
||||
"print(\"Länge der Fahrt:\", length)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
BIN
code/online-part-1/plots_expected_output.png
Normal file
BIN
code/online-part-1/plots_expected_output.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
Loading…
x
Reference in New Issue
Block a user