\documentclass[12pt, a4paper]{article}

%packages
\usepackage[ngerman]{babel}
\usepackage[utf8x]{inputenc}
%Formel packages
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsbsy}
\usepackage{amssymb}


\usepackage{enumerate}


\begin{document}

\section*{Computer Graphics - Excercise 1}
\subsection*{1.1.1}
\subsection*{a)}
\begin{itemize}
\item		Matrix Multiplication $\widehat{=}$ transformation
\item		Inverse of a transformation $\tilde{T}^{-1}$ \\
\begin{align*}
		\Rightarrow && \tilde{T}*\tilde{T}^{-1} &= \tilde{T}^{-1}*\tilde{T} = \tilde{E} && \left |\ *\tilde{p} \right. \\
		&&\tilde{T}^{-1}*\tilde{T}*\tilde{p} &= \tilde{E}*\tilde{p} && \left |\ \tilde{T}*\tilde{p}=\tilde{p'} \right. \\
		\Rightarrow && \tilde{E}*\tilde{p} = \tilde{p}&, \hspace{1em} \tilde{T}^{-1}*\tilde{p'} = \tilde{p} \\
\end{align*}
\end{itemize}
\subsection*{b)}

For $R_1 \times R_2$\\
\begin{gather*}
\begin{pmatrix} a & b & 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} e & f & 0 \\  g& h& 0\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix} a \times e + b \times g& a \times f + b \times h & 0 \\  c \times e + d \times g& c \times f + d \times h & 0\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
For $R_2 \times R_1$\\
\begin{gather*}
\begin{pmatrix} e & f & 0 \\  g& h& 0\\ 0&0&1\\ \end{pmatrix} \times \begin{pmatrix} a & b & 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix}  =\begin{pmatrix} a \times e + c \times f& b \times e + d \times f & 0 \\  a \times g + c \times h& b \times g + d \times h & 0\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow R_1 \times R_2 \neq R_2 \times R_1 \Rightarrow$ does not commute\\

\newpage
\hspace{-2em}
For $T_1 \times T_2$\\
\begin{gather*}
\begin{pmatrix} 1 & 0 & a  \\ 0&1&b\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} 1 & 0 & c \\  0& 1& d\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix}  1& 0 & a+c \\  0& 1 & b+d\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
\hspace{-0.5em}
For $T_2 \times T_1$\\
\begin{gather*}
\begin{pmatrix} 1 & 0 & c  \\ 0&1&d\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} 1 & 0 & a \\  0& 1& b\\ 0&0&1\\ \end{pmatrix}  =\begin{pmatrix}  1& 0 & a+c \\  0& 1 & b+d\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow T_1 \times T_2 = T_2 \times T_1 \Rightarrow$ does commute\\
\\
\hspace{-1.5em}
For $S_1 \times S_2$\\
\begin{gather*}
\begin{pmatrix} a & 0 & 0  \\ 0&b&0\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} c & 0 & 0 \\  0& d& 0\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix} a \times c & 0 & 0 \\ b \times d& 0 & 0\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
For $S_2 \times S_1$\\
\begin{gather*}
\begin{pmatrix} c & 0& 0 \\  0& d& 0\\ 0&0&1\\ \end{pmatrix} \times \begin{pmatrix} a & 0 & 0  \\ 0&b&0\\ 0&0&1 \\ \end{pmatrix}  =\begin{pmatrix} a \times c & 0 & 0 \\ b \times d& 0 & 0\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow S_1 \times S_2 = S_2 \times S_1 \Rightarrow$ does commute\\
\\
\hspace{-1.5em}
For $R \times T$\\
\begin{gather*}
\begin{pmatrix} a & b& 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} 1 & 0 & e \\  0& 1& f\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix}  a& b & a \times e + b \times f \\  c& d & c\times e + d \times f\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
For $T \times R$\\
\begin{gather*}
\begin{pmatrix} 1 & 0 & e \\  0& 1& f\\ 0&0&1\\ \end{pmatrix} \times \begin{pmatrix} a & b& 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix}  =\begin{pmatrix}  a& b & e \\  c& d & f\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow R \times T \neq T \times R \Rightarrow$ does not commute\\
\\
\hspace{-1.5em}
For $R \times S$\\
\begin{gather*}
\begin{pmatrix} a & b& 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} e & 0 & 0 \\  0& f& 0\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix}  a \times e& b \times f & 0 \\  c \times f & d \times f & 0\times e + d \times f\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
For $S \times R$\\
\begin{gather*}
\begin{pmatrix} e & 0 & 0 \\  0& f& 0\\ 0&0&1\\ \end{pmatrix} \times \begin{pmatrix} a & b& 0  \\ c&d&0\\ 0&0&1 \\ \end{pmatrix}  =\begin{pmatrix}  a \times e& b \times f & 0 \\  c \times f & d \times f & 0\times e + d \times f\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow R \times S = S \times R \Rightarrow$ does commute\\
\\
\hspace{-1.5em}
For $S \times T$\\
\begin{gather*}
\begin{pmatrix} 1 & 0 & a  \\ 0&0&b\\ 0&0&1 \\ \end{pmatrix} \times \begin{pmatrix} c & 0 & 0 \\  0& d& 0\\ 0&0&1\\ \end{pmatrix} =\begin{pmatrix} c & 0 & a \\ 0& d & b\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}
For $T \times S$\\
\begin{gather*}
\begin{pmatrix} c & 0 & 0 \\  0& d& 0\\ 0&0&1\\ \end{pmatrix} \times \begin{pmatrix} 1 & 0 & a  \\ 0&0&b\\ 0&0&1 \\ \end{pmatrix}  =\begin{pmatrix} c & 0 & a \times c \\ d& 0 & b \times d\\ 0&0&1 \\ \end{pmatrix}
\end{gather*}

$\Rightarrow S \times T \neq T \times S \Rightarrow$ does not commute\\


\subsection*{1.1.2}
\subsection*{a)}
\begin{gather*}
\begin{pmatrix} 1 & 0 & 0  \\ 0&0&1\\ 0&1&0 \\ \end{pmatrix} \times \begin{pmatrix} x_1 & x_2 & \cdots & x_n \\ y_1&y_2&\cdots&y_n\\ z_1&z_2&\cdots&z_n \\ \end{pmatrix} =\begin{pmatrix} x_1 & x_2 & \cdots & x_n \\ z_1&z_2&\cdots&z_n\\ y_1&y_2&\cdots&y_n \\ \end{pmatrix}
\end{gather*}

\subsection*{b)}
\begin{gather*}
\begin{pmatrix} x_1 & x_2 & \cdots & x_n \\ y_1&y_2&\cdots&y_n\\ z_1&z_2&\cdots&z_n \\ \end{pmatrix} \times \begin{pmatrix} 1 \\ 1 \\ \vdots \\ 1 \\ \end{pmatrix} = 
\begin{pmatrix}  \sum\limits_{i=1} x_i \\ \sum\limits_{i=1} y_i \\ \sum\limits_{i=1} z_i \end{pmatrix}
\end{gather*}

\subsection*{c)}
\begin{gather*}
 \tilde{M} = \begin{pmatrix} M_{11} & M_{12} & M_{13}  & t_x \\ M_{21}&M_{22}& M_{23}&t_y\\ M_{31}&M_{32}&M_{33}&t_z \\ p_x&p_y&p_z&1 \\ \end{pmatrix};
e = \begin{pmatrix} 5 \\ 10 \\ 5 \\\end{pmatrix}= t;
p = \begin{pmatrix} 0 \\ 0 \\ 0 \\ \end{pmatrix}
\end{gather*}
\begin{gather*}
z_\phi = \frac {\begin{pmatrix} 0\\0\\1\\ \end{pmatrix} \times p_x} {1 \times |p_x|} \Rightarrow \begin{pmatrix} cos(z_\phi) & -sin(z_\phi) & 0  \\ sin(z_\phi)&cos(z_\phi)&0\\ 0&0&1 \\ \end{pmatrix}=R_z\\
y_\phi = \frac {\begin{pmatrix} 0\\1\\0\\ \end{pmatrix} \times p_x} {1 \times |p_x|} \Rightarrow \begin{pmatrix} cos(y_\phi) & 0 & sin(y_\phi)  \\ 0 &1 &0\\ -sin(z_\phi)&0&cos(y_\phi) \\ \end{pmatrix}=R_y\\
x_\phi = \frac {\begin{pmatrix} 1\\0\\0\\ \end{pmatrix} \times p_x} {1 \times |p_x|} \Rightarrow \begin{pmatrix} 0 & 0 & 0  \\ 0 &cos(x_\phi)&-sin(x_\phi)\\ 0&sin(x_\phi)&cos(x_\phi) \\ \end{pmatrix}=R_x\\
M = R_x \times R_y \times R_z \\
\end{gather*}
\newpage
Berechnung für: \\
$p_1 = (-1, -1, 1); p_2 = (2, 1, -2); p_3 = (2, 1, -3); p_4 = (-1, -2, 1); p_5 = (3, -1, 0)$
\begin{gather*}
\Rightarrow Vector =\begin{pmatrix}
p_1 \times \tilde{M_1}\\
p_2 \times \tilde{M_2}\\
p_3 \times \tilde{M_3}\\
p_4 \times \tilde{M_4}\\
p_5 \times \tilde{M_5}\\ \end{pmatrix}
=
 \begin{pmatrix}
6.323746006808568\\
2.672777625063053\\
1.6528549605644152\\
6.432049954608068\\
4.731031538265404\\ \end{pmatrix}\\
\Rightarrow z_{far} = p_4 = 6.432049954608068; z_{near} = p_3 = 1.6528549605644152\\
\end{gather*}

\end{document}

