+Adaption of for a 3D–Mesh
+
+This is a straightforward extension of the 1D–method presented in the last chapter. But this time things get a bit more complicated. As we have a 3–dimensional grid we may have a different amount of 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 \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.
+Given a target vertex \(\vec{p}^*\) and an initial guess \(\vec{p}=V(u,v,w)\) we define the error–function for the gradient–descent as:
+\[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 \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 \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,d,\tau_i}(u) N_{j,d,\tau_j}(v) N_{k,d,\tau_k}(w) \cdot {c_{ijk}}_x
+\end{array}
+\]
+The other partial derivatives follow the same pattern yielding the Jacobian:
+\[
+J(Err(u,v,w)) =
+\left(
+\begin{array}{ccc}
+\frac{\partial Err_x}{\partial u} & \frac{\partial Err_x}{\partial v} & \frac{\partial Err_x}{\partial w} \\
+\frac{\partial Err_y}{\partial u} & \frac{\partial Err_y}{\partial v} & \frac{\partial Err_y}{\partial w} \\
+\frac{\partial Err_z}{\partial u} & \frac{\partial Err_z}{\partial v} & \frac{\partial Err_z}{\partial w}
+\end{array}
+\right)
+\] \[
+\scriptsize
+=
+\left(
+\begin{array}{ccc}
+- \displaystyle \sum_{i,j,k} N'_{i}(u) N_{j}(v) N_{k}(w) \cdot {c_{ijk}}_x &- \displaystyle \sum_{i,j,k} N_{i}(u) N'_{j}(v) N_{k}(w) \cdot {c_{ijk}}_x & - \displaystyle \sum_{i,j,k} N_{i}(u) N_{j}(v) N'_{k}(w) \cdot {c_{ijk}}_x \\
+- \displaystyle \sum_{i,j,k} N'_{i}(u) N_{j}(v) N_{k}(w) \cdot {c_{ijk}}_y &- \displaystyle \sum_{i,j,k} N_{i}(u) N'_{j}(v) N_{k}(w) \cdot {c_{ijk}}_y & - \displaystyle \sum_{i,j,k} N_{i}(u) N_{j}(v) N'_{k}(w) \cdot {c_{ijk}}_y \\
+- \displaystyle \sum_{i,j,k} N'_{i}(u) N_{j}(v) N_{k}(w) \cdot {c_{ijk}}_z &- \displaystyle \sum_{i,j,k} N_{i}(u) N'_{j}(v) N_{k}(w) \cdot {c_{ijk}}_z & - \displaystyle \sum_{i,j,k} N_{i}(u) N_{j}(v) N'_{k}(w) \cdot {c_{ijk}}_z
+\end{array}
+\right)
+\]
+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 Cramer’s rule for inverting the small Jacobian and solving this system of linear equations.
+As there is no strict upper bound of the number of iterations for this algorithm, we just iterate it long enough to be within the given \(\epsilon\)–error above. This takes — depending on the shape of the object and the grid — about \(3\) to \(5\) iterations that we observed in practice.
+Another issue that we observed in our implementation is, that multiple local optima may exist on self–intersecting grids. We solve this problem by defining self–intersecting grids to be invalid and do not test any of them.
+This is not such a big problem as it sounds at first, as self–intersections mean, that control–points being further away from a given vertex have more influence over the deformation than control–points closer to this vertex. Also this contradicts the notion of locality that we want to achieve and deemed beneficial for a good behaviour of the evolutionary algorithm.
+
+Because our control–points are arranged in a grid, we can accurately represent each vertex–point inside the grids volume with proper B–Spline–coefficients between \([0,1[\) and — as a consequence — we have to embed our object into it (or create constant “dummy”–points outside).
+The great advantage of B–Splines is the local, direct impact of each control point without having a \(1:1\)–correlation, and a smooth deformation. While the advantages are great, the issues arise from the problem to decide where to place the control–points and how many to place at all.
+
+One would normally think, that the more control–points you add, the better the result will be, but this is not the case for our B–Splines. Given any point \(\vec{p}\) only the \(2 \cdot (d-1)\) control–points contribute to the parametrization of that point. This means, that a high resolution can have many control–points that are not contributing to any point on the surface and are thus completely irrelevant to the solution.
+We illustrate this phenomenon in figure , where the red central points are not relevant for the parametrization of the circle. This leads to artefacts in the deformation–matrix \(\vec{U}\), as the columns corresponding to those control–points are \(0\).
+This also leads to useless increased complexity, as the parameters corresponding to those points will never have any effect, but a naive algorithm will still try to optimize them yielding numeric artefacts in the best and non–terminating or ill–defined solutions at worst.
+One can of course neglect those columns and their corresponding control–points, but this raises the question why they were introduced in the first place. We will address this in a special scenario in .
+For our tests we chose different uniformly sized grids and added noise onto each control–point to simulate different starting–conditions.
+
+