\documentclass[12pt]{article}

\usepackage{amstext}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{enumerate}
\usepackage{alltt}
\usepackage[latin1]{inputenc}
\usepackage{cancel}
\usepackage{fancyhdr}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{ngerman,a4}

\title{\textsc{Computer Graphics I \\ \large Assignment 8 \\ \small Group III (Yavor Kaloyanov)}}
\author{\shortstack[c]{Jan Hendrik Dithmar\\ \footnotesize 2031259} \and \shortstack[c]{Pascal Gwosdek\\ \footnotesize 2505221}}
\date{}

\pagestyle{fancy}

\lhead{Assignment 8}
\chead{}
\rhead{Dithmar (2031259), Gwosdek (2505221)}
\lfoot{Computer Graphics 1}
\cfoot{Page \thepage}
\rfoot{WS 2006/2007}

\begin{document}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}

\newcommand{\exercise}[1]{\subsection{#1}}
\renewcommand{\theenumi}{\textbf{\alph{enumi}}}

\newcommand{\AND}{\ensuremath{\wedge}}
\newcommand{\OR}{\ensuremath{\vee}}
\newcommand{\SetR}{\ensuremath{\mathbb{R}}}
\newcommand{\SetN}{\ensuremath{\mathbb{N}}}
\newcommand{\SetC}{\ensuremath{\mathbb{C}}}
\newcommand{\SetZ}{\ensuremath{\mathbb{Z}}}
\newcommand{\SetQ}{\ensuremath{\mathbb{Q}}}
\newcommand{\SetB}{\ensuremath{\mathbb{B}}}
\newcommand{\QED}{\ensuremath{\hspace*{\fill}\square}}
\newcommand{\FLASH}{\ensuremath{\hspace*{\fill}\lightning}}
\newcommand{\OnotO}{\ensuremath{\mathcal{O}}}
\newcommand{\bild}[4]{
	\begin{figure}[htpb]
		\centering
			\includegraphics[width=#1cm]{#2}\\[0.2cm]
			\caption{#3}
			\label{#4}
	\end{figure}
	}

\newcommand{\m}[1]{\begin{pmatrix}#1\end{pmatrix}}
\newcommand{\+}{\phantom{-}}
\newcommand{\f}{\frac}

\maketitle

\thispagestyle{empty}

\newpage
\setcounter{page}{1}
\setcounter{section}{8}

\exercise{$C^1$ and $G^1$ continuity}
\begin{enumerate}
\item For two curves $q_1, q_2$ it holds:
$$C^1 \Rightarrow G^1$$
\begin{align*}
C^1 & \Leftrightarrow q_1'(n) = q_2'(n) \\
& \stackrel{(*)}{\Rightarrow} \nabla q_1(n) = \nabla q_2(n) \Leftrightarrow G^1
\end{align*}
where $(*)$ holds for $|q_1'(n)| \neq 0$.
\item
\begin{align*}
\gamma(t) &= (t^2,t) \\
\gamma'(t) &= (2t,1) \\
\nu(t) &= (t^3+4t+1,2t+1) \\
\nu'(t) &= (3t^2+4,2) \\
\gamma(1) = (1,1) &, \quad \nu(0) = (1,1) \Rightarrow C^0 \\
\gamma'(1) = (2,1) &, \quad \nu'(0) = (4,2) \Rightarrow 2 \gamma'(1) = \nu'(0) \Rightarrow G^1 \\
& \gamma'(1) \neq \nu'(0) \Rightarrow \mbox{ not } C^1
\end{align*}
\item
\begin{align*}
\gamma(t) &= (t,t^2-2t) \\
\gamma'(t) &= (1,2t-2) \\
\nu(t) &= (t+1,t^2+1) \\
\nu'(t) &= (1,2t) \\
\gamma'(1) = (1,0) & = \nu'(0) = (1,0) \Rightarrow C^1 \Rightarrow G^1
\end{align*}
\end{enumerate}

\exercise{Hermite Spline}
\begin{enumerate}
\item
\begin{align*}
(I) \quad p(0) &= \left(\begin{array}{cccc}a_1 & b_1 & c_1 & d_1 \\ a_2 & b_2 & c_2 & d_2 \\ a_3 & b_3 & c_3 & d_3\end{array}\right) \underbrace{\left(\begin{array}{c}0 \\ 0 \\ 0 \\ 1\end{array}\right)}_{= \left(\begin{array}{c}t^3 \\ t^2 \\ t^1 \\ t^0\end{array}\right) \mbox{ for } t = 0} = \left(\begin{array}{c}0 \\ 1 \\ 0\end{array}\right) \\
(II) \quad p(1) &= \left(\begin{array}{cccc}a_1 & b_1 & c_1 & d_1 \\ a_2 & b_2 & c_2 & d_2 \\ a_3 & b_3 & c_3 & d_3\end{array}\right) \left(\begin{array}{c}1 \\ 1 \\ 1 \\ 1\end{array}\right) = \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) \\
(III) \quad p'(0) &= \left(\begin{array}{cccc}a_1 & b_1 & c_1 & d_1 \\ a_2 & b_2 & c_2 & d_2 \\ a_3 & b_3 & c_3 & d_3\end{array}\right) \underbrace{\left(\begin{array}{c}0 \\ 0 \\ 1 \\ 0\end{array}\right)}_{= \left(\begin{array}{c}3t^2 \\ 2t \\ 1t^0 \\ 0\end{array}\right) \mbox{ for } t = 0} = \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) \\
(IV) \quad p'(1) &= \left(\begin{array}{cccc}a_1 & b_1 & c_1 & d_1 \\ a_2 & b_2 & c_2 & d_2 \\ a_3 & b_3 & c_3 & d_3\end{array}\right) \left(\begin{array}{c}3 \\ 2 \\ 1 \\ 0\end{array}\right) = \left(\begin{array}{r}0 \\ -1 \\ 0\end{array}\right)
\end{align*}
$$d=\left(\begin{array}{c}0 \\ 1 \\ 0\end{array}\right) \mbox{ from } (I), \quad c=\left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) \mbox{ from } (III)$$
$$\Rightarrow \left(\begin{array}{cccc}a_1 & b_1 & 0 & 0 \\ a_2 & b_2 & 0 & 0 \\ a_3 & b_3 & 0 & 0\end{array}\right) \left(\begin{array}{c}1 \\ 1 \\ 1 \\ 1\end{array}\right) = \left(\begin{array}{r}0 \\ -1 \\ 0\end{array}\right) \quad \mbox{and} \quad \left(\begin{array}{cccc}a_1 & b_1 & 0 & 0 \\ a_2 & b_2 & 0 & 0 \\ a_3 & b_3 & 0 & 0\end{array}\right) \left(\begin{array}{c}3 \\ 2 \\ 1 \\ 0\end{array}\right) = \left(\begin{array}{r}-1 \\ -1 \\ -1\end{array}\right)$$
\begin{align*}
\Rightarrow & a_1 = -b_1; a_2 = -1-b_2; a_3 = -b_3 \\
\Rightarrow & -3b_1+2b_1 = -1 \Leftrightarrow b_1 = 1; -3-3b_2+2b_2 = -1 \Leftrightarrow b_2 = -2; \\
& 3b_3+2b_3 = -1 \Leftrightarrow b_3 = 1 \\
\Rightarrow & b = \left(\begin{array}{r}1 \\ -2 \\ 1\end{array}\right) \\
\Rightarrow & a = \left(\begin{array}{r}-1 \\ 1 \\ -1\end{array}\right)
\end{align*}
\item
\begin{align*}
P(t) =& \left(\begin{array}{c}0 \\ 1 \\ 0\end{array}\right) (1-t)^2(1+2t) + \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) t (1-t)^2 \\
& + \left(\begin{array}{r}0 \\ -1 \\ 0\end{array}\right) t^2(1-t) + \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) (3-2t)t^2 \\
=& \left(\begin{array}{c}0 \\ 1 \\ 0\end{array}\right) (2t^3 + 3t^2 +1) + \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) (t^3 - 2t^2 + t) \\
& + \left(\begin{array}{r}0 \\ -1 \\ 0\end{array}\right) (t^3-t^2) + \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) (-2t^3 - 3t^2) \\
=& \left(\begin{array}{r}-1 \\ 1 \\ -1\end{array}\right) t^3 + \left(\begin{array}{r}1 \\ -2 \\ 1\end{array}\right) t^2 + \left(\begin{array}{c}1 \\ 0 \\ 1\end{array}\right) t + \left(\begin{array}{c}0 \\ 1 \\ 0\end{array}\right)
\end{align*}
\end{enumerate}

\exercise{DeCasteljau}
\begin{enumerate}
\item \
\begin{center}
\begin{pspicture}(-.5,-.5)(7,4)
%axes
\psline{->}(0,0)(0,3)
\psline{->}(0,0)(6,0)
\rput(-.2,3){$y$}
\rput(6,-.2){$x$}

%lines
\psline(1,1)(2,2)
\psline(2,2)(5,1)
\psline(5,1)(5,0)
\psline(1.5,1.5)(3.5,1.5)
\psline(3.5,1.5)(5,.5)
\psline(2.5,1.5)(4.25,1)

%dots
\psdot(1,1)
\psdot(2,2)
\psdot(3.375,1.25)
\psdot(5,1)
\psdot(5,0)

%descriptions
\rput(0.7,1){$b_0$}
\rput(1.7,2){$b_1$}
\rput(5.3,1){$b_3$}
\rput(5.3,0.3){$b_4$}
\rput(3,1){$B(\frac12)$}

% Big thing
\rput(4,3){$B(\frac12) \approx (3.4,1.3)$}
\end{pspicture}
\end{center}

\item
\begin{align*}
B_2^3\left(\frac{1}{2}\right) &= \frac{1}{2} \cdot B_1^2\left(\frac{1}{2}\right) + \frac{1}{2} \cdot B_0^2\left(\frac{1}{2}\right) \\
&= \frac{1}{2} \cdot \left(\frac{1}{2} \cdot B_2^1\left(\frac{1}{2}\right) + \frac{1}{2} \cdot B_1^1\left(\frac{1}{2}\right)\right) + \frac{1}{2} \cdot \left(\frac{1}{2} \cdot B_1^1\left(\frac{1}{2}\right) + \frac{1}{2} \cdot B_0^1\left(\frac{1}{2}\right)\right) \\
&= \frac{1}{4} \cdot B_2^1\left(\frac{1}{2}\right) + \frac{1}{2} \cdot B_1^1\left(\frac{1}{2}\right) + \frac{1}{4} \cdot B_0^1\left(\frac{1}{2}\right) \\
&= \frac{1}{4} \left(\frac{1}{2} (5,0) + \frac{1}{2} (5,1)\right) + \frac{1}{2} \left(\frac{1}{2} (5,1) + \frac{1}{2} (2,2)\right) + \frac{1}{4} \left(\frac{1}{2} (2,2) + \frac{1}{2} (1,1)\right) \\
&= \left(\frac{5}{4}, \frac{1}{8}\right) + \left(\frac{7}{4}, \frac{3}{4}\right) + \left(\frac{3}{8}, \frac{3}{8}\right) \\
&= \left(\frac{27}{8}, \frac{10}{8}\right) = (3.375, 1.250)
\end{align*}
\end{enumerate}

\exercise{Bezier Splines}
\begin{align*}
A(t) &= a_0(1-t)^3 + 3a_1 t(1-t)^2 + 3a_2 t^2(1-t) + a_3 t^3 \\
&= a_0(-t^3 + 3t^2 - 3t - 1) + 3a_1(t^3 - 2t^2 + t) + 3a_2(-t^3 + t^2) + a_3 t^3 \\
&= t^3(-a_0 + 3a_1 - 3a_2 + a_3) + t^2(3a_0 - 6a_1 + 3a_2) + t(-3a_0 + 3a_1) - 3a_0 \\
A'(t) &= 3t^2(-a_0 + 3a_1 - 3a_2 + a_3) + 2t(3a_0 - 6a_1 + 3a_2) + (-3a_0 + 3a_1)
\end{align*}
analogously:
\begin{align*}
B'(t) &= 3t^2(-b_0 + 3b_1 - 3b_2 + b_3) + 2t(3b_0 - 6b_1 + 3b_2) + (-3b_0 + 3b_1) \\
A'(1) &= 3(-a_0 + 3a_1 - 3a_2 + a_3) + 2(3a_0 - 6a_1 + 3a_2) - (3a_0 + 3a_1) = -3a_2 + 3a_3 \\
B'(0) &= -3b_0 + 3b_1 \\
A'(1) &= -3a_2 + 3a_3 = 3(a_3 - a_2) \stackrel{a_3 - a_2 = b_1 - b_2}{=} 3(b_1 - b_0) \\
&= -3b_0 + 3b_1 = B'(0) \Rightarrow C^1; a_3 = b_0 \Rightarrow C^0
\end{align*}

\end{document}
