<p>Assuming a value is assigned to each vertex of the mesh and we use purely linear interpolation, then there will be a constant gradient vector within each tetrahedron.</p>
<p>Linear interpolation can be expressed using barycentric coordinates, like
<span class="math-container">$$
f(x,y,z) = f_1 w_1(x,y,z) + f_2 w_2(x,y,z) + f_3 w_3(x,y,z) + f_4 w_4(x,y,z)
$$</span>
where <span class="math-container">$f_1 \ldots f_4$</span> are the values of the function at the four vertices, and <span class="math-container">$w_1 \ldots w_4$</span> are the barycentric weights for each vertex. Then, finding the gradient of <span class="math-container">$f$</span> reduces to finding the gradients of all of the weights.</p>
<p>This can be worked out geometrically by noting that each <span class="math-container">$w_i$</span> is 1 at the <span class="math-container">$i$</span>th vertex, falling off to 0 at the plane formed by the other three vertices. The gradient vector will therefore be normal to that plane, pointing back towards the <span class="math-container">$i$</span>th vertex, with a magnitude equal to 1 / the distance from the plane to the vertex.</p>
<p>Once you've calculated those barycentric gradients, you can multiply them by <span class="math-container">$f_1 \ldots f_4$</span> and sum them up to arrive at the gradient of <span class="math-container">$f$</span> overall.</p>
<p>This reasoning works for triangles too, by the way, only replace &quot;plane&quot; with &quot;line&quot;.</p>

CC BY-SA 4.0
2020-08-31T01:16:24.613Z
Is there a similar way to compute the Laplacian operator for 3D mesh?
Bis
CC BY-SA 4.0
2020-08-31T02:33:13.917Z
Laplacians are tricky to even define, because it's a second-derivative operator, so with linear interpolation it would just be zero. Getting a useful answer out of it requires defining some higher-order interpolation scheme first. You can see some approaches to this in [Laplace–Beltrami: The Swiss Army Knife of Geometry Processing](http://ddg.cs.columbia.edu/SGP2014/LaplaceBeltrami.pdf)
Nathan Reed
CC BY-SA 4.0
2020-08-30T06:31:41.933Z
2020-08-30T06:31:41.933Z
Nathan Reed
<p>How can I compute the gradient for a tetrahedral mesh (3D)? For triangular mesh, I got an answer from the following post <a href="https://computergraphics.stackexchange.com/questions/8835/calculating-the-gradient-of-a-triangular-mesh">Calculating the gradient of a triangular mesh</a></p>
<p>How can I get a similar formula for 3D mesh?</p>
<p>Thanks in advance.</p>

<computational-geometry><mesh><gradient>
Calculating the gradient of a tetrahedral mesh
Bis
# Calculating the gradient of a tetrahedral mesh

(Asked by: username_0 on 2020-08-25)

How can I compute the gradient for a tetrahedral mesh (3D)? For triangular mesh, I got an answer from the following post [Calculating the gradient of a triangular mesh](https://computergraphics.stackexchange.com/questions/8835/calculating-the-gradient-of-a-triangular-mesh)

How can I get a similar formula for 3D mesh?

Thanks in advance.

**Tags:** computational-geometry, mesh, gradient


---

## 1 answers

### Answer by username_1 on 2020-08-30. Score: 1 | Accepted answer

Assuming a value is assigned to each vertex of the mesh and we use purely linear interpolation, then there will be a constant gradient vector within each tetrahedron.

Linear interpolation can be expressed using barycentric coordinates, like
$$
f(x,y,z) = f\_1 w\_1(x,y,z) + f\_2 w\_2(x,y,z) + f\_3 w\_3(x,y,z) + f\_4 w\_4(x,y,z)
$$
where $f\_1 \ldots f\_4$ are the values of the function at the four vertices, and $w\_1 \ldots w\_4$ are the barycentric weights for each vertex. Then, finding the gradient of $f$ reduces to finding the gradients of all of the weights.

This can be worked out geometrically by noting that each $w\_i$ is 1 at the $i$th vertex, falling off to 0 at the plane formed by the other three vertices. The gradient vector will therefore be normal to that plane, pointing back towards the $i$th vertex, with a magnitude equal to 1 / the distance from the plane to the vertex.

Once you've calculated those barycentric gradients, you can multiply them by $f\_1 \ldots f\_4$ and sum them up to arrive at the gradient of $f$ overall.

This reasoning works for triangles too, by the way, only replace "plane" with "line".

> **Comments:**
> **username_0**: Is there a similar way to compute the Laplacian operator for 3D mesh?  
> **username_1**: Laplacians are tricky to even define, because it's a second-derivative operator, so with linear interpolation it would just be zero. Getting a useful answer out of it requires defining some higher-order interpolation scheme first. You can see some approaches to this in [Laplace–Beltrami: The Swiss Army Knife of Geometry Processing](http://ddg.cs.columbia.edu/SGP2014/LaplaceBeltrami.pdf)  

---

