CDS104-Databases-and-Data-P.../code/part-2/Roboterfahrt Aufgabe 1.ipynb
2025-05-12 20:21:35 +02:00

133 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "00d20df1",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"id": "b986454c",
"metadata": {},
"source": [
"## Übung: Roboterbewegung\n",
"\n",
"Ein Roboter steht in einem Raum, seine Position auf dem Boden wird in ein Koordinatensystem eingetragen - die y-Achse ist dabei die Himmelsrichtung _Nord_, die x-Achse die Himmelsrichtung _Ost_. Zu Beginn steht der Roboter auf der Position $x=3$ und $y=5$. Danach führt der Roboter folgende Bewegungen durch.\n",
"\n",
"- Fahrt 1 Meter Ost, 2 Meter Nord\n",
"- Fahrt 2 Meter Ost, 1 Meter Nord\n",
"- Fahrt 2 Meter Ost, 1 Meter Süd\n",
"- Fahrt 1 Meter West, 3 Meter Süd\n",
"\n",
"a) Drücken Sie die 4 Bewegungen als Arrays aus und speichern Sie diese in Python-Variablen."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bec0fab0",
"metadata": {},
"outputs": [],
"source": [
"start = np.array([3,5])\n",
"fahrt1 = ...\n",
"fahrt2 = ...\n",
"fahrt3 = ...\n",
"fahrt4 = ..."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e55f20bc",
"metadata": {},
"outputs": [],
"source": [
"# Mit dieser Zelle können Sie die Fahrt des Roboters plotten - einfach ausführen\n",
"def plot_path(start, moves):\n",
" path = np.vstack([start] + moves).cumsum(axis=0)\n",
" plt.plot(path[:,0], path[:,1])\n",
" plt.xlim((0,10))\n",
" plt.ylim((0,10))\n",
"\n",
"plot_path(start, [fahrt1, fahrt2, fahrt3, fahrt4])"
]
},
{
"cell_type": "markdown",
"id": "9f47078c",
"metadata": {},
"source": [
"b) Berechnen Sie den Zielpunkt des Roboters nach seiner Fahrt."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "90852486",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "3c8684d8",
"metadata": {},
"source": [
"c) Welche Strecke hat der Roboter zurückgelegt (nicht der direkte Weg)?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ee1ca50",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "3474df24",
"metadata": {},
"source": [
"d) Wie weit wäre der Roboter gefahren, wenn er die direkte Strecke von Start zu Ziel gefahren wäre?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04a2e60a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}