Skip to content

Commit e1578f0

Browse files
committed
[L3] Adding starting frame as zero to the SO(3) example.
1 parent 2dc93fc commit e1578f0

1 file changed

Lines changed: 157 additions & 34 deletions

File tree

‎basic_lessons/lesson2_tutorial.ipynb‎

Lines changed: 157 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,19 @@
5353
},
5454
{
5555
"cell_type": "code",
56-
"metadata": {},
56+
"metadata": {
57+
"ExecuteTime": {
58+
"end_time": "2026-02-08T11:48:53.982411Z",
59+
"start_time": "2026-02-08T11:48:52.996429Z"
60+
}
61+
},
5762
"source": [
5863
"%%capture\n",
5964
"%pip install numpy\n",
6065
"%pip install numpy --break-system-packages"
6166
],
6267
"outputs": [],
63-
"execution_count": null
68+
"execution_count": 1
6469
},
6570
{
6671
"cell_type": "markdown",
@@ -71,13 +76,18 @@
7176
},
7277
{
7378
"cell_type": "code",
74-
"metadata": {},
79+
"metadata": {
80+
"ExecuteTime": {
81+
"end_time": "2026-02-08T11:48:53.989102Z",
82+
"start_time": "2026-02-08T11:48:53.983066Z"
83+
}
84+
},
7585
"source": [
7686
"import numpy as np\n",
7787
"from math import pi, sin, cos"
7888
],
7989
"outputs": [],
80-
"execution_count": null
90+
"execution_count": 2
8191
},
8292
{
8393
"cell_type": "markdown",
@@ -127,15 +137,27 @@
127137
{
128138
"cell_type": "code",
129139
"metadata": {
130-
"trusted": true
140+
"trusted": true,
141+
"ExecuteTime": {
142+
"end_time": "2026-02-08T11:48:53.995284Z",
143+
"start_time": "2026-02-08T11:48:53.989652Z"
144+
}
131145
},
132146
"source": [
133147
"p = np.array([1.0, 2.0])\n",
134148
"\n",
135149
"print(f\"p={p}\")"
136150
],
137-
"outputs": [],
138-
"execution_count": null
151+
"outputs": [
152+
{
153+
"name": "stdout",
154+
"output_type": "stream",
155+
"text": [
156+
"p=[1. 2.]\n"
157+
]
158+
}
159+
],
160+
"execution_count": 3
139161
},
140162
{
141163
"cell_type": "markdown",
@@ -158,7 +180,11 @@
158180
{
159181
"cell_type": "code",
160182
"metadata": {
161-
"trusted": true
183+
"trusted": true,
184+
"ExecuteTime": {
185+
"end_time": "2026-02-08T11:48:54.008003Z",
186+
"start_time": "2026-02-08T11:48:54.002363Z"
187+
}
162188
},
163189
"source": [
164190
"p0 = np.array([1.0, 2.0])\n",
@@ -170,8 +196,16 @@
170196
"\n",
171197
"print(f\"p={p}\")"
172198
],
173-
"outputs": [],
174-
"execution_count": null
199+
"outputs": [
200+
{
201+
"name": "stdout",
202+
"output_type": "stream",
203+
"text": [
204+
"p=[10. 14.]\n"
205+
]
206+
}
207+
],
208+
"execution_count": 4
175209
},
176210
{
177211
"cell_type": "markdown",
@@ -191,7 +225,11 @@
191225
{
192226
"cell_type": "code",
193227
"metadata": {
194-
"trusted": true
228+
"trusted": true,
229+
"ExecuteTime": {
230+
"end_time": "2026-02-08T11:48:54.022625Z",
231+
"start_time": "2026-02-08T11:48:54.014821Z"
232+
}
195233
},
196234
"source": [
197235
"p0 = np.array([1.0, 2.0])\n",
@@ -204,8 +242,16 @@
204242
"\n",
205243
"print(f\"p_={p_}\")"
206244
],
207-
"outputs": [],
208-
"execution_count": null
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"p_=[0. 0.]\n"
251+
]
252+
}
253+
],
254+
"execution_count": 5
209255
},
210256
{
211257
"cell_type": "markdown",
@@ -234,7 +280,11 @@
234280
{
235281
"cell_type": "code",
236282
"metadata": {
237-
"trusted": true
283+
"trusted": true,
284+
"ExecuteTime": {
285+
"end_time": "2026-02-08T11:48:54.033749Z",
286+
"start_time": "2026-02-08T11:48:54.028105Z"
287+
}
238288
},
239289
"source": [
240290
"θ = pi/2\n",
@@ -244,8 +294,17 @@
244294
"\n",
245295
"print(f\"R={R}\")"
246296
],
247-
"outputs": [],
248-
"execution_count": null
297+
"outputs": [
298+
{
299+
"name": "stdout",
300+
"output_type": "stream",
301+
"text": [
302+
"R=[[ 6.123234e-17 -1.000000e+00]\n",
303+
" [ 1.000000e+00 6.123234e-17]]\n"
304+
]
305+
}
306+
],
307+
"execution_count": 6
249308
},
250309
{
251310
"cell_type": "markdown",
@@ -282,7 +341,11 @@
282341
{
283342
"cell_type": "code",
284343
"metadata": {
285-
"trusted": true
344+
"trusted": true,
345+
"ExecuteTime": {
346+
"end_time": "2026-02-08T11:48:54.053367Z",
347+
"start_time": "2026-02-08T11:48:54.039405Z"
348+
}
286349
},
287350
"source": [
288351
"θ = pi/2\n",
@@ -296,8 +359,18 @@
296359
"\n",
297360
"print(f\"H = {H}\")"
298361
],
299-
"outputs": [],
300-
"execution_count": null
362+
"outputs": [
363+
{
364+
"name": "stdout",
365+
"output_type": "stream",
366+
"text": [
367+
"H = [[ 6.123234e-17 -1.000000e+00 1.000000e-01]\n",
368+
" [ 1.000000e+00 6.123234e-17 2.000000e-01]\n",
369+
" [ 0.000000e+00 0.000000e+00 1.000000e+00]]\n"
370+
]
371+
}
372+
],
373+
"execution_count": 7
301374
},
302375
{
303376
"cell_type": "markdown",
@@ -341,7 +414,11 @@
341414
{
342415
"cell_type": "code",
343416
"metadata": {
344-
"trusted": true
417+
"trusted": true,
418+
"ExecuteTime": {
419+
"end_time": "2026-02-08T11:48:54.067078Z",
420+
"start_time": "2026-02-08T11:48:54.054258Z"
421+
}
345422
},
346423
"source": [
347424
"Rz = np.array([[cos(θ),-sin(θ), 0],\n",
@@ -365,8 +442,24 @@
365442
"# A rotation about x\n",
366443
"print(f\"Rx={Rx}\")"
367444
],
368-
"outputs": [],
369-
"execution_count": null
445+
"outputs": [
446+
{
447+
"name": "stdout",
448+
"output_type": "stream",
449+
"text": [
450+
"Rz=[[ 6.123234e-17 -1.000000e+00 0.000000e+00]\n",
451+
" [ 1.000000e+00 6.123234e-17 0.000000e+00]\n",
452+
" [ 0.000000e+00 0.000000e+00 1.000000e+00]]\n",
453+
"Ry=[[ 6.123234e-17 0.000000e+00 1.000000e+00]\n",
454+
" [ 0.000000e+00 1.000000e+00 0.000000e+00]\n",
455+
" [-1.000000e+00 0.000000e+00 6.123234e-17]]\n",
456+
"Rx=[[ 1.000000e+00 0.000000e+00 0.000000e+00]\n",
457+
" [ 0.000000e+00 6.123234e-17 -1.000000e+00]\n",
458+
" [ 0.000000e+00 1.000000e+00 6.123234e-17]]\n"
459+
]
460+
}
461+
],
462+
"execution_count": 8
370463
},
371464
{
372465
"cell_type": "markdown",
@@ -376,20 +469,24 @@
376469
"\n",
377470
"Compositions in SO(3) follow the same rules as SO(2), where sequential rotations are represented by right multiplications. For instance,\n",
378471
"\n",
379-
"$$\\mymatrix{R}_c = \\mymatrix{R}_a\\mymatrix{R}^a_b\\mymatrix{R}^b_c.$$\n",
472+
"$$\\mymatrix{R}^0_c \\mymatrix{R}^0_a\\mymatrix{R}^a_b\\mymatrix{R}^b_c.$$\n",
380473
"\n",
381474
"This can be represented by the following equivalent piece of code using sample angles."
382475
]
383476
},
384477
{
385478
"cell_type": "code",
386479
"metadata": {
387-
"trusted": true
480+
"trusted": true,
481+
"ExecuteTime": {
482+
"end_time": "2026-02-08T11:48:54.082984Z",
483+
"start_time": "2026-02-08T11:48:54.068586Z"
484+
}
388485
},
389486
"source": [
390-
"θa = pi/4\n",
391-
"Ra = np.array([[cos(θa),-sin(θa), 0],\n",
392-
" [sin(θa), cos(θa), 0],\n",
487+
"θ0_a = pi/4\n",
488+
"R0_a = np.array([[cos(θ0_a),-sin(θ0_a), 0],\n",
489+
" [sin(θ0_a), cos(θ0_a), 0],\n",
393490
" [0, 0, 1]])\n",
394491
"\n",
395492
"θa_b = -pi/2\n",
@@ -402,11 +499,21 @@
402499
" [0, cos(θb_c), -sin(θb_c)],\n",
403500
" [0, sin(θb_c), cos(θb_c)]])\n",
404501
"\n",
405-
"Rc = Ra @ Ra_b @ Rb_c\n",
406-
"print(f\"Rc={Rc}\")"
502+
"R0_c = R0_a @ Ra_b @ Rb_c\n",
503+
"print(f\"R0_c={R0_c}\")"
407504
],
408-
"outputs": [],
409-
"execution_count": null
505+
"outputs": [
506+
{
507+
"name": "stdout",
508+
"output_type": "stream",
509+
"text": [
510+
"R0_c=[[ 4.32978028e-17 -9.23879533e-01 -3.82683432e-01]\n",
511+
" [ 4.32978028e-17 3.82683432e-01 -9.23879533e-01]\n",
512+
" [ 1.00000000e+00 2.34326020e-17 5.65713056e-17]]\n"
513+
]
514+
}
515+
],
516+
"execution_count": 9
410517
},
411518
{
412519
"cell_type": "markdown",
@@ -420,7 +527,11 @@
420527
{
421528
"cell_type": "code",
422529
"metadata": {
423-
"trusted": true
530+
"trusted": true,
531+
"ExecuteTime": {
532+
"end_time": "2026-02-08T11:48:54.180705Z",
533+
"start_time": "2026-02-08T11:48:54.083625Z"
534+
}
424535
},
425536
"source": [
426537
"Ra_ = Rc @ Rb_c.T @ Ra_b.T \n",
@@ -430,8 +541,20 @@
430541
"else:\n",
431542
" print('The results are too different.')\n"
432543
],
433-
"outputs": [],
434-
"execution_count": null
544+
"outputs": [
545+
{
546+
"ename": "NameError",
547+
"evalue": "name 'Rc' is not defined",
548+
"output_type": "error",
549+
"traceback": [
550+
"\u001B[31m---------------------------------------------------------------------------\u001B[39m",
551+
"\u001B[31mNameError\u001B[39m Traceback (most recent call last)",
552+
"\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[10]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m Ra_ = \u001B[43mRc\u001B[49m @ Rb_c.T @ Ra_b.T \n\u001B[32m 3\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m np.allclose(Ra, Ra_):\n\u001B[32m 4\u001B[39m \u001B[38;5;28mprint\u001B[39m(\u001B[33m'\u001B[39m\u001B[33mThe results are pretty much the same!\u001B[39m\u001B[33m'\u001B[39m)\n",
553+
"\u001B[31mNameError\u001B[39m: name 'Rc' is not defined"
554+
]
555+
}
556+
],
557+
"execution_count": 10
435558
},
436559
{
437560
"cell_type": "markdown",

0 commit comments

Comments
 (0)