\documentclass[a4paper,12pt]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage{graphicx} %BIlder einbinden
\usepackage{amsmath} %erweiterte Mathe-Zeichen
\usepackage{amsfonts} %weitere fonts
\usepackage[utf8]{inputenc} %Umlaute & Co
\usepackage{hyperref} %Links
\usepackage{ifthen} %ifthenelse
\usepackage{enumerate}
\usepackage{pdfpages}
\usepackage{algpseudocode} %Pseudocode
\usepackage{dsfont} % schöne Zahlenräumezeichen
\usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen
\usepackage{tikz} %TikZ ist kein Zeichenprogramm
\usetikzlibrary{trees,automata,arrows,shapes}

\pagestyle{empty}


\topmargin-50pt

\newcounter{aufgabe}
\def\tand{&}

\newcommand{\makeTableLine}[2][0]{%
  \setcounter{aufgabe}{1}%
  \whiledo{\value{aufgabe} < #1}%
  {%
    #2\tand\stepcounter{aufgabe}%
  }
}

\newcommand{\aufgTable}[1]{
  \def\spalten{\numexpr #1 + 1 \relax}
  \begin{tabular}{|*{\spalten}{p{1cm}|}}
    \makeTableLine[\spalten]{A\theaufgabe}$\Sigma$~~\\ \hline
    \rule{0pt}{15pt}\makeTableLine[\spalten]{}\\
  \end{tabular}
}

\def\header#1#2#3#4#5#6#7{\pagestyle{empty}
\begin{minipage}[t]{0.47\textwidth}
\begin{flushleft}
{\bf #4}\\
#5
\end{flushleft}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{flushright}
#6 \vspace{0.5cm}\\
%                 Number of Columns    Definition of Columns      second empty line
% \begin{tabular}{|*{5}{C{1cm}|}}\hline A1&A2&A3&A4&$\Sigma$\\\hline&&&&\\\hline\end{tabular}\\\vspace*{0.1cm}
\aufgTable{#7}
\end{flushright}
\end{minipage}
\vspace{1cm}
\begin{center}
{\Large\bf Assignment #1}

{(Hand-in date #3)}
\end{center}
}



%counts the exercisenumber
\newcounter{n}

%Kommando für Aufgaben
%\Aufgabe{AufgTitel}{Punktezahl}
\newcommand{\Aufgabe}[2]{\stepcounter{n}
\textbf{Exercise \arabic{n}: #1} (#2 Punkte)\\}




\begin{document}
    %\header{BlattNr}{Tutor}{Abgabedatum}{Vorlesungsname}{Namen}{Semester}{Anzahl Aufgaben}
    \header{6}{}{2015-06-16}{Mobile Robots}{
    	\textit{Jan-Peter Hohloch}\\ \textit{Maximus Mutschler}
    }{SS 15}{3}
    \vspace{1cm}

	\Aufgabe{Essential Matrix}{8}
	\begin{enumerate}[(a)]
		\item  $^LT_R= \begin{pmatrix}
		0.9811 &-0.1736 &0.0858& 0.1000\\
		0.1730 &0.9848 &0.0151& 0\\
		-0.0872& 0 &0.9962& 0\\
		0 &0 &0 &1.0000
		\end{pmatrix}\\
		R=	\begin{pmatrix}
		0.9811 &-0.1736 &0.0858\\
		0.1730 &0.9848 &0.0151\\
		-0.0872& 0 &0.9962\\
		\end{pmatrix}\\
		t=\begin{pmatrix}
		0.1&0&0
		\end{pmatrix}\\
		\left[t\right] = \begin{pmatrix}
		0&0&0\\
		0&0&-0.1\\
		0&0.1&0
		\end{pmatrix}\\
		E= \left[t\right] \times R= \begin{pmatrix}
		0&0&0\\
		0.00872&0&-0.09962\\
		0.01730&0.09848&0.00151\\
		\end{pmatrix}
		$
		\item match if $n^T_R\cdot E\cdot n_L=0\\
		n_L= \begin{pmatrix}
		1.33,&0.54&1.0
		\end{pmatrix}
		$\begin{itemize}
		\item $n_{R,1}\rightarrow \begin{pmatrix}
		0.3&0.2&1.0
		\end{pmatrix}
	\begin{pmatrix}
	0&0&0\\
	0.00872&0&-0.09962\\
	0.01730&0.09848&0.00151\\
	\end{pmatrix}
		\begin{pmatrix}
		1.33,\\0.54\\1.0
		\end{pmatrix}\\ =\begin{pmatrix}
		0.3&0.2&1.0
		\end{pmatrix} \begin{pmatrix}
		0\\-0.0880224\\0.0776982
		\end{pmatrix}
		$\\
		\item $n_{R,2}\rightarrow\begin{pmatrix}
		-0.39&0.32&1.0
		\end{pmatrix}
		 \begin{pmatrix}
		 0\\-0.0880224\\0.0776982
		 \end{pmatrix}
		$\\
	\item $n_{R,3}\rightarrow\begin{pmatrix}
		-0.25&0.1&1.0
		\end{pmatrix}
	 \begin{pmatrix}
	 0\\-0.0880224\\0.0776982
	 \end{pmatrix}$
			\end{itemize}
			werte falsch ... finde rechenfehler nicht.

	\item $(K^{-1} p_R)^T\cdot E\cdot K^{-1}p_L = p_R^{T}\cdot K^{T^{-1}}\cdot E\cdot K^{-1} \cdot p_L\\
	E= K^T\cdot F\cdot K	\\
	F= K^{T^{-1}}\cdot E\cdot K^{-1}$\\
	K = calibration matrix of the cameras
	\item
	$
	K=\begin{pmatrix}
	500&0&320\\
	0&500&240\\
	0&0&1
	\end{pmatrix}
	$\\$
	p_{R0}= K\cdot \begin{pmatrix}
		0.3&0.2&1.0
	\end{pmatrix}^T = \begin{pmatrix}
	470\\
	340\\
	1
	\end{pmatrix}\\
	p_{R1}= K\cdot \begin{pmatrix}
		-0.39&0.32&1.0
	\end{pmatrix}^T= \begin{pmatrix}
	125\\
	400\\
	1
	\end{pmatrix}\\
	p_{R2}=K\cdot \begin{pmatrix}
		-0.25&0.1&1.0
	\end{pmatrix}^T = \begin{pmatrix}
	195\\
	290\\
	1
	\end{pmatrix}
	$
	Epipolar Line: $ =E \cdot p_L^T $  wie bekomm ich daraus ne linie? %TODO \\
	epipolatpunkt $E^T*e_2 =0$
	\end{enumerate}
	\Aufgabe{RANSAC}{4}
	\begin{enumerate}[(a)]
		\item  $
		k=\dfrac{log(1-p)}{log(1(1-\epsilon)^s)}\\
		p=0.99\\
		s_1=4, s_2=6, s_3=7\\
		\begin{tabular}{c||llllllllll}
			 outlier ratio  & 0.1  &0.2  &0.3  &0.4  &0.5  &0.6  &0.7  &0.8  &0.9    \\ \hline
			s1=4& 5 & 9 & 17 & 34 & 72 & 178 & 567  & 2876  & 4650     \\
			s2=5 & 6 & 12 &26  &57  &146  &448  &1893  &14389  &460515    \\
			s3=7 & 8 &20  & 54 &163  &588  &2809  &21055  &359777  &46051700
		\end{tabular}
		$
		\item A: 4 datapoints 150ns a iteration\\
		B: 5 datapoints 40ns a iteration\\
		$p=0.99\\
		\eta = 0.7\\
		k_A= 567\\
		k_B=1893\\
		k_A\cdot t_A=567\cdot 140ns=79380ns\\
        k_B\cdot t_B=1893\cdot 40ns= 75720ns$\\
        So the time for computation of B is smaller even with more points needed. So we choose B because of faster computationtime. If we are short for points however we should use A even though it takes more time.

	\end{enumerate}
	\Aufgabe{Stereo Vision}{8}
	\begin{enumerate}[(a)]
		\item  As $d_{max}$ increases $z_b$ decreases. So $d_{max}$ sets a lower bound. For $d$ appoaching 0 $z_b$ goes to infinity, so there is no upper bound set by setting $d_{max}$\\
		$z_{p,min}=\frac{f\cdot b}{d_{max}}=\frac{512px\cdot10cm}{64px}=\frac{2^9}{2^6}\cdot10cm=80cm$
		\item
		$  d \sim N(d_{true},\sigma_d)$\\
		 $z_{p}(d)=\frac{f\cdot b}{d}$\\
		TaylorApprox:\\$z_p(d)=z(d_{true})+z'(d_{true})(d-d_{true})=\frac{f\cdot b}{d_{true}}- \frac{f\cdot b}{d_{true}^2}(d-d_{true})= \frac{2f\cdot b}{d_{true}}-\frac{f\cdot b}{d_{true}^2}\cdot d\\
		\sigma_z= |A|\cdot \sigma_d =  \frac{f\cdot b}{d_{true}^2}\cdot \sigma_d= \frac{f\cdot b}{\frac{f^2\cdot b^2}{z_p^2}}\cdot \sigma_d= \frac{z_p^2}{f\cdot b}\sigma_d  \\
		$schneller: $\sigma = |f'(a)|\cdot \sigma_{alt}
		$
		\item see b)
		\item $f=512px \\
		b=5cm\\
		\sigma_d=0.5px\\
		z_p=500cm\\
		\sigma_z= \frac{500^2}{512\cdot5}\cdot 0.5=\frac{500^2}{512\cdot 2}\approx 244.1cm
		$
		\item $\sigma_{z}=5cm\\
		b=\frac{z_p^2}{f\cdot o_z}\sigma_d= \frac{500^2}{512\cdot5}\cdot \sigma_d= 97.65625\frac{cm}{px}\cdot\sigma_d$\\
        for $\sigma_d=0.5px:\ b=97.65625\frac{cm}{px}\cdot 0.5px=48.828125cm$
	\end{enumerate}
\end{document}

