diff --git a/arbeit/ma.md b/arbeit/ma.md index 8bf9d2b..18b42e1 100644 --- a/arbeit/ma.md +++ b/arbeit/ma.md @@ -204,12 +204,12 @@ $\|\vec{G}\|_F = 1$, whereby $\|\cdot\|_F$ denotes the Frobenius-Norm. # Implementation of \acf{FFD} -As general B-Splines have a free parameters $d$ and $\tau$. +The general formulation of B-Splines has two free parameters $d$ and $\tau$ +which must be chosen beforehand. As we usually work with regular grids in our \ac{FFD} we define $\tau$ -statically as -$$\tau_i = \nicefrac{i}{n}$$ -whereby $n$ is the number of control-points in that direction. +statically as $\tau_i = \nicefrac{i}{n}$ whereby $n$ is the number of +control-points in that direction. $d$ defines the *degree* of the B-Spline-Function (the number of times this function is differentiable) and for our purposes we fix $d$ to $3$, but give the @@ -237,16 +237,18 @@ position of the vertex we first have to calculate the $u$-value for each vertex. This is achieved by finding out the parametrization of $v$ in terms of $c_i$ $$ -v_x = \sum_i N_{i,d,\tau_i}(u) c_i +v_x \overset{!}{=} \sum_i N_{i,d,\tau_i}(u) c_i +$$ +so we can minimize the error between those two: +$$ +\underset{u}{\argmin}\,Err(u,v_x) = \underset{u}{\argmin}\,2 \cdot \|v_x - \sum_i N_{i,d,\tau_i}(u) c_i\|^2_2 $$ -As the B-Spline-functions are smooth and convex we just derive by $u$ yielding - +As this error-term is quadratic we just derive by $u$ yielding \begin{eqnarray*} & \frac{\partial}{\partial u} & v_x - \sum_i N_{i,d,\tau_i}(u) c_i \\ -& = & v_x - \sum_i \left( \frac{d}{\tau_{i+d} - \tau_i} N_{i,d-1,\tau}(u) - \frac{d}{\tau_{i+d+1} - \tau_{i+1}} N_{i+1,d-1,\tau}(u) \right) c_i +& = & - \sum_i \left( \frac{d}{\tau_{i+d} - \tau_i} N_{i,d-1,\tau}(u) - \frac{d}{\tau_{i+d+1} - \tau_{i+1}} N_{i+1,d-1,\tau}(u) \right) c_i \end{eqnarray*} - and do a gradient-descend to approximate the value of $u$ up to an $\epsilon$ of $0.0001$. For this we use the Gauss-Newton algorithm\cite{gaussNewton} as the solution to @@ -263,7 +265,7 @@ direction. Given $n,m,o$ control points in $x,y,z$-direction each Point on the curve is defined by -$$V(u,v,w) = \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot C_{ijk}.$$ +$$V(u,v,w) = \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot C_{ijk}.$$ In this case we have three different B-Splines (one for each dimension) and also 3 variables $u,v,w$ for each vertex we want to approximate. @@ -275,14 +277,14 @@ $$Err(u,v,w,\vec{p}^{*}) = \vec{p}^{*} - V(u,v,w)$$ And the partial version for just one direction as -$$Err_x(u,v,w,\vec{p}^{*}) = p^{*}_x - \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) $$ +$$Err_x(u,v,w,\vec{p}^{*}) = p^{*}_x - \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x $$ To solve this we derive partially, like before: $$ \begin{array}{rl} - \displaystyle \frac{\partial Err_x}{\partial u} & p^{*}_x - \displaystyle \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \\ - = & \displaystyle - \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N'_i(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) + \displaystyle \frac{\partial Err_x}{\partial u} & p^{*}_x - \displaystyle \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x \\ + = & \displaystyle - \sum_i \sum_j \sum_k N'_i(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x \end{array} $$ @@ -303,7 +305,7 @@ $$ Like leaving out Sums & $i,j,k$-Indices to make obvious what derivative belongs where in what case?} -With the Gauss-Newton algorithm we iterate the formula +With the Gauss-Newton algorithm we iterate via the formula $$J(Err(u,v,w)) \cdot \Delta \left( \begin{array}{c} u \\ v \\ w \end{array} \right) = -Err(u,v,w)$$ and use Cramers rule for inverting the small Jacobian and solving this system of linear equations. diff --git a/arbeit/ma.pdf b/arbeit/ma.pdf index a1ca29b..d7f9df3 100644 Binary files a/arbeit/ma.pdf and b/arbeit/ma.pdf differ diff --git a/arbeit/ma.tex b/arbeit/ma.tex index 28aec77..9221ff3 100644 --- a/arbeit/ma.tex +++ b/arbeit/ma.tex @@ -237,7 +237,7 @@ evolutionary optimization\cite{Menzel2006}, which we will use later on. \begin{figure}[!ht] \includegraphics[width=\textwidth]{img/hsu_fig7.png} -\caption{Figure 7 from \cite{hsu1991dmffd}} +\caption{Figure 7 from \cite{hsu1991dmffd}.} \label{fig:hsu_fig7} \end{figure} @@ -340,10 +340,11 @@ Frobenius-Norm. \chapter{\texorpdfstring{Implementation of \acf{FFD}}{Implementation of }}\label{implementation-of} -As general B-Splines have a free parameters \(d\) and \(\tau\). +The general formulation of B-Splines has two free parameters \(d\) and +\(\tau\) which must be chosen beforehand. As we usually work with regular grids in our \ac{FFD} we define \(\tau\) -statically as \[\tau_i = \nicefrac{i}{n}\] whereby \(n\) is the number +statically as \(\tau_i = \nicefrac{i}{n}\) whereby \(n\) is the number of control-points in that direction. \(d\) defines the \emph{degree} of the B-Spline-Function (the number of @@ -372,15 +373,16 @@ high-detailed vertex-mesh to the low-detailed control-grid. To actually calculate the new position of the vertex we first have to calculate the \(u\)-value for each vertex. This is achieved by finding out the parametrization of \(v\) in terms of \(c_i\) \[ -v_x = \sum_i N_{i,d,\tau_i}(u) c_i +v_x \overset{!}{=} \sum_i N_{i,d,\tau_i}(u) c_i +\] so we can minimize the error between those two: \[ +\underset{u}{\argmin}\,Err(u,v_x) = \underset{u}{\argmin}\,2 \cdot \|v_x - \sum_i N_{i,d,\tau_i}(u) c_i\|^2_2 \] -As the B-Spline-functions are smooth and convex we just derive by \(u\) -yielding +As this error-term is quadratic we just derive by \(u\) yielding \begin{eqnarray*} & \frac{\partial}{\partial u} & v_x - \sum_i N_{i,d,\tau_i}(u) c_i \\ -& = & v_x - \sum_i \left( \frac{d}{\tau_{i+d} - \tau_i} N_{i,d-1,\tau}(u) - \frac{d}{\tau_{i+d+1} - \tau_{i+1}} N_{i+1,d-1,\tau}(u) \right) c_i +& = & - \sum_i \left( \frac{d}{\tau_{i+d} - \tau_i} N_{i,d-1,\tau}(u) - \frac{d}{\tau_{i+d+1} - \tau_{i+1}} N_{i+1,d-1,\tau}(u) \right) c_i \end{eqnarray*} and do a gradient-descend to approximate the value of \(u\) up to an @@ -402,7 +404,7 @@ control-points in each direction. Given \(n,m,o\) control points in \(x,y,z\)-direction each Point on the curve is defined by -\[V(u,v,w) = \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot C_{ijk}.\] +\[V(u,v,w) = \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot C_{ijk}.\] In this case we have three different B-Splines (one for each dimension) and also 3 variables \(u,v,w\) for each vertex we want to approximate. @@ -415,14 +417,14 @@ gradient-descent as: And the partial version for just one direction as -\[Err_x(u,v,w,\vec{p}^{*}) = p^{*}_x - \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \] +\[Err_x(u,v,w,\vec{p}^{*}) = p^{*}_x - \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x \] To solve this we derive partially, like before: \[ \begin{array}{rl} - \displaystyle \frac{\partial Err_x}{\partial u} & p^{*}_x - \displaystyle \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \\ - = & \displaystyle - \sum_{i=0}^{n-d-2} \sum_{j=0}^{m-d-2} \sum_{k=0}^{o-d-2} {C_{ijk}}_x N'_i(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) + \displaystyle \frac{\partial Err_x}{\partial u} & p^{*}_x - \displaystyle \sum_i \sum_j \sum_k N_{i,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x \\ + = & \displaystyle - \sum_i \sum_j \sum_k N'_i(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x \end{array} \] @@ -444,7 +446,7 @@ J(Err(u,v,w)) = Like leaving out Sums & $i,j,k$-Indices to make obvious what derivative belongs where in what case?} -With the Gauss-Newton algorithm we iterate the formula +With the Gauss-Newton algorithm we iterate via the formula \[J(Err(u,v,w)) \cdot \Delta \left( \begin{array}{c} u \\ v \\ w \end{array} \right) = -Err(u,v,w)\] and use Cramers rule for inverting the small Jacobian and solving this system of linear equations.