Update code
This commit is contained in:
parent
91e0ee5752
commit
0d847f19c7
@ -45,7 +45,9 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Linienzug plotten\n",
|
"# Linienzug plotten\n",
|
||||||
"# plt.plot(...)\n"
|
"plt.figure()\n",
|
||||||
|
"plt.plot(n[0], n[1])\n",
|
||||||
|
"plt.show()\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -73,11 +75,14 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"# angle soll in Grad angegeben werden\n",
|
"# angle soll in Grad angegeben werden\n",
|
||||||
"def rotation_matrix(angle):\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",
|
"\n",
|
||||||
"# mögliche Tests\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]))\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"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -94,9 +99,11 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# n_rot soll die rotierten Punkte enthalten, n_rot.shape == n.shape\n",
|
"# 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",
|
"\n",
|
||||||
"# und erneut plotten..."
|
"plt.figure()\n",
|
||||||
|
"plt.plot(n_rot[0], n_rot[1])\n",
|
||||||
|
"plt.show()\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -123,10 +130,9 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def scale_matrix(sx, sy):\n",
|
"def scale_matrix(sx, sy):\n",
|
||||||
" pass\n",
|
" return np.array([[sx, 0], [0, sy]])\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"assert np.allclose(scale_matrix(2, 3).dot(np.array([1,1])), np.array([2,3]))\n"
|
||||||
"# todo test schreiben?"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -142,12 +148,12 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Punkte skalieren\n",
|
"scaled = scale_matrix(2, 0.5).dot(n)\n",
|
||||||
"\n",
|
"plt.figure()\n",
|
||||||
"\n",
|
"plt.plot(n[0], n[1], label=\"original\")\n",
|
||||||
"\n",
|
"plt.plot(scaled[0], scaled[1], label=\"scaled\")\n",
|
||||||
"# und plotten\n",
|
"plt.legend()\n",
|
||||||
"\n"
|
"plt.show()\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 1,
|
||||||
"id": "00d20df1",
|
"id": "00d20df1",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
@ -108,7 +108,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 21,
|
"execution_count": null,
|
||||||
"id": "6ee1ca50",
|
"id": "6ee1ca50",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -121,8 +121,8 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"lenght = sum([np.linalg.norm(f) for f in fahrten])\n",
|
"length = sum([np.linalg.norm(f) for f in fahrten])\n",
|
||||||
"print(\"Länge der Fahrt:\", lenght)"
|
"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