~~NOTOC~~
===== Homework 04 - Rigid motion as a coordinate transformation =====
=== Motivation ===
//In this task, we will study the effect of motion (rotation and translation) on a //rigid body//.
To study this, we construct a very simple rigid body $r_1$ consisting of only two points $r_1=\{O, X\}$. To describe the relative position of these two points, we introduce a coordinate system $(O, \beta)$ with the origin at one of these points - $O$ and the standard basis $\beta$. The second point $X$ can thus be expressed as a vector $\vec{x}_\beta$ in this coordinate system. We set $\vec{x}_\beta = [1,2,3]^\top$.
Now we apply the given motion on this rigid body represented by the coordinate system. That will result in a new coordinate system $(O', \beta')$. We construct a new rigid body $r_2 = \{O', Y\}$ where $Y$ has the same relative pose as $X$ in $r_1$, i.e. $\vec{y}'_{\beta'} = [1,2,3]^\top$, where $\vec{y}'$ is a vector expressing $Y$ in $(O', \beta')$.
Finally, we apply the motion on point $X$ denoting it as $Z$.
What are the coordinates of point $Z$?//
----
=== Task ===
Use Python to solve the following problems related to rigid motion. Use different colors to display your results.
- Simulate the rigid motion with matrix $R$ and translation $\overrightarrow{O'O}_{\beta'}$ prescribed by Equation 5.4 in {{http://cmp.felk.cvut.cz/cmp/courses/PRO/Lecture/PRO-Lecture.pdf|PRO-Lecture.pdf}}.
# approximate rotation
R = np.array([[0.8047, -0.5059, -0.3106],
[0.3106, 0.8047, -0.5059],
[0.5059, 0.3106, 0.8047]])
# less approximate rotation
u, s, vh = np.linalg.svd(R)
R = u.dot(vh)
# translation O'O_β'
o_beta_pr = np.array([[1], [1], [1]])
- Basis $\beta$ equals the standard basis $\sigma$. $O$=[0, 0, 0]
- Find the coordinates of vectors of $\beta'$ in $\beta$ and vice versa.
- Plot vectors of $\beta$ and $\beta'$ in the standard basis.
- Plot coordinate systems ($O$, $\beta$) and ($O'$, $\beta'$ ). i.e. plot the basic vectors as bound vectors originating from points $O$ and $O'$, respectively.
- Plot the bound vector $\vec{x}_\beta$ = $[1,2,3]^\top$ representing point $X$ in ($O$, $\beta$ ).
- Plot the position vector in ($O'$, $\beta'$ ) of point $Y$ represented in ($O'$, $\beta'$ ) by vector $\vec{y}_{\beta'}$ = $[1,2,3]^\top$.
- Consider point $Z$, where $X$ moves by the motion given above. Plot the bound vector representing the point $Z$ w.r.t. ($O$, $\beta$).
=== Upload ===
Create an empty dictionary in Python:
solution = {}
The keys for this dictionary will be:
* ''"b1_beta_pr"'' (3x1), ''"b2_beta_pr"'' (3x1), ''"b3_beta_pr"'' (3x1) containing the coordinates of vectors of $\beta$ in $\beta'$
* ''"b1_pr_beta"'' (3x1), ''"b2_pr_beta"'' (3x1), ''"b3_pr_beta"'' (3x1) containing the coordinates of vectors of $\beta'$ in $\beta$
* ''"oz_beta"'' (3x1) containing the coordinates of $\overrightarrow{OZ}_\beta$.
Finally, save ''solution'' to ''hw04.json'':
import json
with open("hw04.json", "w") as outfile:
json.dump(solution, outfile)
Upload a zip archive ''hw04.zip'' (via the [[https://cw.felk.cvut.cz/upload/|course ware]]) containing the following files:
- ''hw04.py'' - python script used for computation
- ''hw04.pdf'' - report file describing your solution with all figures
- ''hw04.json''