Could you please help me with finding the affine transformation matrix for the question given below. The question asks for the calculation of the rotation equation of a vector to some other coordinates in 3D.
Calculation of affine transformation matrix for 3D rotation of vectors
1.1k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 2 best solutions below
On
Maybe what you are looking for is the (3+1)-dimensional "homogeneous coordinate" model, in order to linearize translations (which unlike rotation and scaling, are not linear transformation, as they displace the origin of your vector space).
Any linear transformation in 3D
$$ \quad \begin{bmatrix} x_1 & y_1 & z_1\\ x_2 & y_2 & z_2\\ x_3 & y_3 & z_3 \end{bmatrix} \quad \quad \begin{bmatrix} x\\ y\\ z \end{bmatrix} \quad $$
followed by a translation
\begin{bmatrix} t_1\\ t_2\\ t_3 \end{bmatrix}
can be expressed
$$ \quad \begin{bmatrix} x_1 & y_1 & z_1 & t_1\\ x_2 & y_2 & z_2 & t_2\\ x_3 & y_3 & z_3 & t_3\\ 0 & 0 & 0 & 1 \end{bmatrix} \quad \quad \begin{bmatrix} x\\ y\\ z\\ 1 \end{bmatrix} \quad $$
In what is called the homogeneous coordinate model. Its goal is to linearize translations by embedding an $n$-dimensional space into an $(n+1)$-dimensional space. (It is of great use and importance in CGI.)
A simple translation is just the identity matrix followed by a translation, and thus resembles:
\begin{bmatrix} 1 & 0 & 0 & t_1\\ 0 & 1 & 0 & t_2\\ 0 & 0 & 1 & t_3\\ 0 & 0 & 0 & 1 \end{bmatrix}
A simple rotation is a linear transformation without a translation, and thus resembles:
\begin{bmatrix} x_1 & y_1 & z_1 & 0\\ x_2 & y_2 & z_2 & 0\\ x_3 & y_3 & z_3 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}
A rotation $R$ around a point $p = [p_1 \space p_2 \space p_3]^T$ which is not the origin is a translation from $p$ to $0$ (to put $p$ at the origin), followed by the rotation $R$, followed by a return from the origin $0$ to $p$, and can thus be expressed as the following product:
$$ \quad \begin{bmatrix} 1 & 0 & 0 & p_1\\ 0 & 1 & 0 & p_2\\ 0 & 0 & 1 & p_3\\ 0 & 0 & 0 & 1 \end{bmatrix} \quad \quad \begin{bmatrix} x_1 & y_1 & z_1 & 0\\ x_2 & y_2 & z_2 & 0\\ x_3 & y_3 & z_3 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \quad \quad \begin{bmatrix} 1 & 0 & 0 & -p_1\\ 0 & 1 & 0 & -p_2\\ 0 & 0 & 1 & -p_3\\ 0 & 0 & 0 & 1 \end{bmatrix} \quad $$
which I leave to you to simplify if you need.
You can use this general framework to define each of the operations in your problem, and apply them in sequence/multiply the matrices together to find a single matrix that solves your problem.

Let's use a convention where matrices are represented by uppercase latin, vectors by lowercase latin, and scalars by greek letters.
For ease of typing, define the following variables according to the above convention. $$\rho_k = \cos(\phi_k),\quad \sigma_k = \sin(\phi_k),\quad\lambda_k=L_k$$ Denote the Cartesian base vectors at the origins $(\cal C_0, C_2, C_3)$ as $(e_k,f_k,g_k)$ respectively.
The basis vectors are related by simple rotations $(R,Q)$ $$\eqalign{ f_k &= Re_k \\ g_k &= Qf_k = QRe_k \\ }$$ which can be calculated via the Rodrigues formula, i.e. $$\eqalign{ R &= &e_1e_1^T &+\,\sigma_1\big(e_3e_2^T-e_2e_3^T\big) &+\,\rho_1\big(e_2e_2^T+e_3e_3^T\big) \\ Q &= &f_3f_3^T &+\,\sigma_3\big(f_2f_1^T-f_1f_2^T\big) &+\,\rho_3\big(f_1f_1^T+f_2f_2^T\big) \\ }$$ Note that $f_1=Re_1=e_1$ and $g_3=Qf_3=f_3\;$ which will be used to simplify later expressions.
Displacements between the origins are given by the vectors $$\eqalign{ u &= \lambda_1f_2 + \lambda_2f_1 &= \lambda_1Re_2 + \lambda_2e_1 &= ({\cal C_2-C_0}) \\ w &= \lambda_3g_1 = \lambda_3QRe_1 &= \lambda_3Qe_1 &= ({\cal C_3-C_2}) \\ }$$ The vector $a'$ at origin $\cal C_3$ $$\eqalign{ a' &= \alpha'_1g_1 + \alpha'_2g_2 + \alpha'_3g_3 \\ &= \alpha'_1QRe_1 + \alpha'_2QRe_2 + \alpha'_3Qf_3 \\ &= \alpha'_1Qe_1 + \alpha'_2QRe_2 + \alpha'_3Re_3 \\ }$$ equals the vector $a$ at origin $\cal C_0$ plus the two displacements, i.e. $$\eqalign{ a &= a' + u + w \\ &= \Big(\alpha'_1Qe_1 + \alpha'_2QRe_2 + \alpha'_3Re_3\Big) + \Big(\lambda_1Re_2 + \lambda_2Ie_1 + \lambda_3Qe_1\Big) \\ &= \Big(\alpha'_1Q+\lambda_2I+\lambda_3Q\Big)e_1 + \Big(\alpha'_2QR+\lambda_1R\Big)e_2 + \Big(\alpha'_3R\Big)e_3\\ &= \alpha_1e_1 + \alpha_2e_2 + \alpha_3e_3 \\ }$$ I'm not sure what sort of canonical form you're aiming for, so I'll leave it there.
Or maybe you're just looking for the following form? $$a = R^TQ^Ta' + (u+w) = Ma' + v$$