Skip to content

Instantly share code, notes, and snippets.

@shrinktofit
Last active April 20, 2022 10:29
Show Gist options
  • Save shrinktofit/a53e5ceef632e436d0bcf3940182d18b to your computer and use it in GitHub Desktop.
Save shrinktofit/a53e5ceef632e436d0bcf3940182d18b to your computer and use it in GitHub Desktop.
Calculate world position, rotation and scale
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}
Let RS(denoted as $R$) be "rotation then scale". \\
RS then translation(denoted as $t$):
$$
\begin{bmatrix}
1 & t\\
0 & 1
\end{bmatrix}
\times
\begin{bmatrix}
R & 0\\
0 & 1
\end{bmatrix}
=
\begin{bmatrix}
R & t\\
0 & 1
\end{bmatrix}
$$
Two RS:
$$
\begin{bmatrix}
R_1 & 0\\
0 & 1
\end{bmatrix}
\times
\begin{bmatrix}
R_2 & 0\\
0 & 1
\end{bmatrix}
=
\begin{bmatrix}
R_1 \times R_2 & 0\\
0 & 1
\end{bmatrix}
$$
Two TRS transforms:
$$
\begin{bmatrix}
R_2 & t_2\\
0 & 2
\end{bmatrix}
\times
\begin{bmatrix}
R_1 & t_1\\
0 & 1
\end{bmatrix}
=
\begin{bmatrix}
R_2 \times R_1 & R_2 \times t_1 + t_2 \\
0 & 1
\end{bmatrix}
$$
Conclusion:
\begin{itemize}
\item The global translation of a node can be calculated as successively(from direct parent to root) apply the local transforms to the local translation of the node.
\item The global rotation(or scale) of a node can be calculated as successively(from direct parent to root) apply the local rotation and local scale to the local rotation(or scale) of the node.
\end{itemize}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment