<p>Maybe something quick (to set up, no guarantees of actual speed) and dirty. </p>

<p>Whatever your method was, it probably boiled down to a vector function 
<span class="math-container">\begin{align}
\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\Big([s,\, t,\, u] \,\, \Big| \,\, V_{ijk} \, : i,j,k = 1..N\Big)
\end{align}</span>  where <span class="math-container">$V_{ijk} \in \mathbb{R}^3$</span>are the vertices of the three dimensional lattice.</p>

<p>Basically, you currently have the new coordinates <span class="math-container">$[x,\, y,\, z]$</span> of a point, and you want to find the original ones <span class="math-container">$[s,\, t,\, u]$</span>. I hope you still have the coordinates of the lattice vertices <span class="math-container">$V_{ijk}$</span>. To retrieve the initial coordinates <span class="math-container">$[s,\, t,\, u]$</span> you have to solve for <span class="math-container">$[s,\, t,\, u]$</span> the system of equations
<span class="math-container">\begin{align}
\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\Big([s,\, t,\, u] \,\, \Big| \,\, V_{ijk} \, : i,j,k = 1..N\Big)
\end{align}</span> where <span class="math-container">$[x,\, y,\, z]$</span> is given and the points <span class="math-container">$V_{ijk}$</span> are given 
For simplicity, I am going to write 
<span class="math-container">$$\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\big([s,\, t,\, u] \,\, \big| \,\, V \,\big)$$</span>
To solve it, use a type of Newton's method.
Set a small enough number <span class="math-container">$h$</span>. </p>

<p>Set your initial <span class="math-container">$s_0=x, t_0=y, u_0=z$</span> and set up your error equal to <span class="math-container">$err = 1$</span> (or whatever).</p>

<p>While <span class="math-container">$err \geq h^2$</span> execute the following iteration:</p>

<ol>
<li><p>Assume you have a current approximation <span class="math-container">$[s_n,\, t_n,\, u_n]$</span>;</p></li>
<li><p>Calculate the following three three-vector (as rows) 
<span class="math-container">\begin{align}
&amp;\Delta_s F_n = \frac{1}{h} \Big( \, F\big([s_n+h,\, t_n,\, u_n] \,\, \big| \,\, V \,\big) - F\big([s_n,\, t_n,\, u_n] \,\, \Big| \,\, V \,\big) \, \Big)\\
&amp;\Delta_t F_n = \frac{1}{h} \Big( \, F\big([s_n,\, t_n+h,\, u_n] \,\, \big| \,\, V \,\big) - F\big([s_n,\, t_n,\, u_n] \,\, \Big| \,\, V \,\big) \, \Big)\\
&amp;\Delta_u F_n = \frac{1}{h} \Big( \, F\big([s_n,\, t_n,\, u_n+h] \,\, \big| \,\, V \,\big) - F\big([s_n,\, t_n,\, u_n] \,\, \Big| \,\, V \,\big) \, \Big)
\end{align}</span>   </p></li>
<li><p>Set the following three by three matrix 
<span class="math-container">$$M_n = \begin{bmatrix} \Delta_s F_n \\  \Delta_t F_n \\ 
   \Delta_u F_n\end{bmatrix}$$</span> (the vectors are the ones computed above but transposed and are therefore vector-columns);</p></li>
<li><p>Calculate the inverse matrix <span class="math-container">$M_n^{-1}$</span>;</p></li>
<li><p>Calculate the update
<span class="math-container">$$[s_{n+1},\, t_{n+1},\, u_{n+1}] = [s_n,\, t_n,\, u_n] + \Big(\,[x,\, y,\, z] - F\big([s_n,\, t_n,\, u_n] \,\, \Big| \,\, V \,\big)\,\Big)\, M_n^{-1}$$</span> 
(all of this is written as vector matrix multiplication, where you are working with <span class="math-container">$1 \times 3$</span> row-vectors and multiplying such<span class="math-container">$1 \times 3$</span> row-vectors with the <span class="math-container">$3 \times 3$</span> matrix <span class="math-container">$M_n^{-1}$</span> on the right)</p></li>
<li><p>Calculate the error <span class="math-container">$$err = \Big\|\, [x,\, y,\, z] - F\big([s_{n+1},\, t_{n+1},\, u_{n+1}] \,\, \Big| \,\, V \,\big)\, \Big\|^2$$</span></p></li>
<li><p>Go back to the beginning of the iteration to check whether <span class="math-container">$err \geq h^2$</span></p></li>
</ol>

<p>The result of this iteration is an approximation of the coordinates <span class="math-container">$[s,\, t,\, u]$</span>. I hope this works. </p>

CC BY-SA 4.0
2019-05-01T22:39:54.980Z
2019-05-01T22:39:54.980Z
Futurologist
<p>I'm making a lattice based volume FFD and I'm having trouble with gaps in my data resulting from doing a typical deformer. I think I need to go through the voxels in the deformed lattice and then find the corresponding undeformed coordinate, that is, go from having the deformed position to getting the local (s,t,u) coordinate that was deformed to that position and then write the interpolated value of the original voxel. This is obviously the opposite way of doing a lattice based FFD with vector valued trivariate Bernstein polynomials.</p>

<p>I am struggling to figure out a way to get the local coordinates of a point in the deformed volume. If anyone has any advice it would be much appreciated.</p>

<p>Thank you!</p>

CC BY-SA 4.0
2020-05-26T10:51:47.777Z
Could you please add a small screenshot of the gaps? I can't imagine what you mean by _gaps from a typical deformer_.
Isolin
<volumetric>
Local Coordinates of Deformed Lattice
clueless deformer
# Local Coordinates of Deformed Lattice

(Asked by: username_0 on 2019-04-29)

I'm making a lattice based volume FFD and I'm having trouble with gaps in my data resulting from doing a typical username_0. I think I need to go through the voxels in the deformed lattice and then find the corresponding undeformed coordinate, that is, go from having the deformed position to getting the local (s,t,u) coordinate that was deformed to that position and then write the interpolated value of the original voxel. This is obviously the opposite way of doing a lattice based FFD with vector valued trivariate Bernstein polynomials.

I am struggling to figure out a way to get the local coordinates of a point in the deformed volume. If anyone has any advice it would be much appreciated.

Thank you!

**Tags:** volumetric

> **Comments:**
> **username_1**: Could you please add a small screenshot of the gaps? I can't imagine what you mean by _gaps from a typical deformer_.  

---

## 1 answers

### Answer by username_2 on 2019-05-01. Score: 1

Maybe something quick (to set up, no guarantees of actual speed) and dirty.

Whatever your method was, it probably boiled down to a vector function
\begin{align}
\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\Big([s,\, t,\, u] \,\, \Big| \,\, V\_{ijk} \, : i,j,k = 1..N\Big)
\end{align} where $V\_{ijk} \in \mathbb{R}^3$are the vertices of the three dimensional lattice.

Basically, you currently have the new coordinates $[x,\, y,\, z]$ of a point, and you want to find the original ones $[s,\, t,\, u]$. I hope you still have the coordinates of the lattice vertices $V\_{ijk}$. To retrieve the initial coordinates $[s,\, t,\, u]$ you have to solve for $[s,\, t,\, u]$ the system of equations
\begin{align}
\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\Big([s,\, t,\, u] \,\, \Big| \,\, V\_{ijk} \, : i,j,k = 1..N\Big)
\end{align} where $[x,\, y,\, z]$ is given and the points $V\_{ijk}$ are given
For simplicity, I am going to write
$$\begin{bmatrix} x,\, y,\, z\end{bmatrix} = F\big([s,\, t,\, u] \,\, \big| \,\, V \,\big)$$
To solve it, use a type of Newton's method.
Set a small enough number $h$.

Set your initial $s\_0=x, t\_0=y, u\_0=z$ and set up your error equal to $err = 1$ (or whatever).

While $err \geq h^2$ execute the following iteration:

1. Assume you have a current approximation $[s\_n,\, t\_n,\, u\_n]$;
2. Calculate the following three three-vector (as rows)
   \begin{align}
   &\Delta\_s F\_n = \frac{1}{h} \Big( \, F\big([s\_n+h,\, t\_n,\, u\_n] \,\, \big| \,\, V \,\big) - F\big([s\_n,\, t\_n,\, u\_n] \,\, \Big| \,\, V \,\big) \, \Big)\\
   &\Delta\_t F\_n = \frac{1}{h} \Big( \, F\big([s\_n,\, t\_n+h,\, u\_n] \,\, \big| \,\, V \,\big) - F\big([s\_n,\, t\_n,\, u\_n] \,\, \Big| \,\, V \,\big) \, \Big)\\
   &\Delta\_u F\_n = \frac{1}{h} \Big( \, F\big([s\_n,\, t\_n,\, u\_n+h] \,\, \big| \,\, V \,\big) - F\big([s\_n,\, t\_n,\, u\_n] \,\, \Big| \,\, V \,\big) \, \Big)
   \end{align}
3. Set the following three by three matrix
   $$M\_n = \begin{bmatrix} \Delta\_s F\_n \\ \Delta\_t F\_n \\
   \Delta\_u F\_n\end{bmatrix}$$ (the vectors are the ones computed above but transposed and are therefore vector-columns);
4. Calculate the inverse matrix $M\_n^{-1}$;
5. Calculate the update
   $$[s\_{n+1},\, t\_{n+1},\, u\_{n+1}] = [s\_n,\, t\_n,\, u\_n] + \Big(\,[x,\, y,\, z] - F\big([s\_n,\, t\_n,\, u\_n] \,\, \Big| \,\, V \,\big)\,\Big)\, M\_n^{-1}$$
   (all of this is written as vector matrix multiplication, where you are working with $1 \times 3$ row-vectors and multiplying such$1 \times 3$ row-vectors with the $3 \times 3$ matrix $M\_n^{-1}$ on the right)
6. Calculate the error $$err = \Big\|\, [x,\, y,\, z] - F\big([s\_{n+1},\, t\_{n+1},\, u\_{n+1}] \,\, \Big| \,\, V \,\big)\, \Big\|^2$$
7. Go back to the beginning of the iteration to check whether $err \geq h^2$

The result of this iteration is an approximation of the coordinates $[s,\, t,\, u]$. I hope this works.


---

