2
$\begingroup$

I wonder if there is a technique for fitting a surface to a given mesh grid of data points? I've seen interpolating a polynomial to $2$D data, but not $3$D.

E.g. say I was given the matrix $$ H=\left(\begin{array}{cccc} 1 & 32 & 245 & 45 \\ 5 & 145 & 134 & 54 \\ 9 & 2 & 67 & 24\\ 12 & 99 & 121 & 201 \end{array}\right), $$

could I construct a function $f(x,y)=z$ where $x,y$ are the discrete points and $z$ is the corresponding matrix value? Many thanks.

| cite | improve this question | | | | |
$\endgroup$
  • 2
    $\begingroup$ Try bilinear interpolation. $\endgroup$ – lhf Dec 15 '14 at 12:21
  • $\begingroup$ @lhf thanks, I'll have a Google. $\endgroup$ – Mike Miller Dec 15 '14 at 14:04
2
$\begingroup$

Try bicubic Bézier surface patch.

$z=f(u,v)=U\cdot C\cdot P\cdot C\cdot V^T$, where $U=[u^3\ u^2\ u\ 1],\ V=[v^3\ v^2\ v\ 1]$, $C=\left[\begin{array}{cccc} -1 & 3 & -3 & 1 \\ 3 & -6 & 3 & 0 \\ -3 & 3 & 0 & 0 \\ 1 & 0 & 0 & 0 \end{array}\right]$, $P=\left[\begin{array}{cccc} P_{00} & P_{01} & P_{02} & P_{03} \\ P_{10} & P_{11} & P_{12} & P_{13} \\ P_{20} & P_{21} & P_{22} & P_{23} \\ P_{30} & P_{31} & P_{32} & P_{33} \end{array}\right]$.

To find 16 control points $P_{00}\dots P_{33}$, consider given matrix

$H=\left[\begin{array}{cccc} 1 & 32 & 245 & 45 \\ 5 & 145 & 134 & 54 \\ 9 & 2 & 67 & 24\\ 12 & 99 & 121 & 201 \end{array}\right]= \left[\begin{array}{cccc} f(0,0) & f(0,\frac13) & f(0,\frac23) & f(0,1) \\ f(\frac13,0) & f(\frac13,\frac13) & f(\frac13,\frac23) & f(\frac13,1) \\ f(\frac23,0) & f(\frac23,\frac13) & f(\frac23,\frac23) & f(\frac23,1) \\ f(1,0) & f(1,\frac13) & f(1,\frac23) & f(1,1) \end{array}\right]$.

Hint: it is easier to find the outer points first and then solve a system for $P_{11},P_{12},P_{21},P_{22}$.

The picture shows how the function $f(u,v)$ looks like for the given $H$:

enter image description here

| cite | improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Thanks, that looks great. Is it computationally expensive for large grids do you happen to know? $\endgroup$ – Mike Miller Dec 16 '14 at 0:40
  • 1
    $\begingroup$ @Mike Miller: I believe that interpolation of large grids based on bicubic Bézier patch as a building block would be within reasonable limits. $\endgroup$ – g.kov Dec 16 '14 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.