# Fitting a surface to scalar functions given on the edges of a triangulation

Given a triangle mesh $\mathcal{T}$ with vertices $V=\{\mathbf{v}_i\}_{i=1}^n$ in $\mathbb{R}^3$ and triangles $T_{ijk}=[\mathbf{v}_i, \mathbf{v}_j, \mathbf{v}_k]$.

For each vertex $\mathbf{v}_i$, I have a scalar value $f_v(\mathbf{v}_i)=U_i$.

For each edge $\mathbf{e}_j$, connecting vertices $\mathbf{v}_a$ and $\mathbf{v}_b$, I have a scalar function $f_e(\mathbf{e}_j, t) = At^2+Bt+C$. The scalars $A$, $B$ and $C$ are chosen such that for $t\in[0,1]$ the edge function $f_e$ interpolates $f_v$ in its vertices, i.e. $f_e(\mathbf{e}_j,0)=U_a$ and $f_e(\mathbf{e}_j, 1)=U_b$.

I wish to find a function $f(\mathbf{p}), \mathbf{p}\in\mathcal{T}$ which interpolates all the edge functions.

I suppose the simplest solution is to seek an interpolating surface locally on each triangle. The surfaces over each triangle would then join with $\mathcal{C}^0$ continuity across edges in $\mathcal{T}$.

What is the best way to find a surface on $T_{ijk}$ which interpolates the functions on all three edges?

Bonus question: Is it possible to get $\mathcal{C}^1$ continuity between patches across each edge?

You could do this kind of stuff with finite elements. Maybe you're familiar with the linear scalar nodal interpolation functions, you can construct your interpolant from a higher order variant. For C0 continuity and quadratic completeness there should be 6 basis functions per triangle, one at each vertex and one at each midpoint. The vertex functions are of the form $\lambda_0\cdot(1-2\lambda_0)$ and $\lambda_1\cdot(1-2\lambda_1)$ and $\lambda_2\cdot(1-2\lambda_2)$, while the midpoint functions are of the form $4\cdot\lambda_0\cdot\lambda_1$ and $4\cdot\lambda_1\cdot\lambda_2$ and $4\cdot\lambda_2\cdot\lambda_0$. (For all of these, $\lambda_0/\lambda_1/\lambda_2$ denote barycentric coordinates). Basically you would just sample your given data at the vertices/midpoints, and those would be the weights/"unknowns" used to scale each basis function. Sum the weighted functions to form your interpolant.
This can be accomplished by using a "total degree surface", see this reference (you will also need to look over the rest of the course notes). Note that a piecewise linear surface is defined uniquely by your $U_i$, giving you $C^0$ continuity. The piecewise linear surface interpolation requires only values local to a triangle. To achieve $C^1$ continuity, you need to use a piecewise quadratic surface, which will require information over the neighborhood of an edge. Note that a piecewise quadratic surface is specified by more information than just $U_i$. Since you have the values at the midpoints of the edges, that should be enough. In any case, the right way to think about the problem is in terms of spline surfaces.