3
$\begingroup$

I have a 3D mesh that is looking like this: enter image description here

ie I have a set of triangles in a 3D space, and they are all linked by their edge. I have to compute the gradient associated with this field, at each edge of the mesh. For a continuous function it would be the derivative along the X and Y axis, but in this case I can't do this. How can I compute this? I'm not even sure how I can define the (approximate) gradient in this situation.

thanks

$\endgroup$
2
  • $\begingroup$ Is there a function $f(\mathbf{x}), x \in \mathbb{R}^3$, whose gradient $\nabla f$ should be evaluated at all vertices/edges of your mesh? Or is f only defined on the mesh? For me "gradient associated with this field" is unclear in your question. Do you have any further information on the problem? $\endgroup$
    – ArminB
    May 9, 2013 at 17:01
  • $\begingroup$ @ArminB : the mesh is an approximation of z = sin(x+y) . I have to compare the gradient of this mesh to the gradient of the exact function. So for my question I need to compute the gradient just based on this approximate mesh $\endgroup$
    – lezebulon
    May 9, 2013 at 17:16

1 Answer 1

3
$\begingroup$

Express your problem differently:

If you keep in mind that "the gradient of a function at a point is perpendicular to the level set of the function at that point" - ie that for a function defining a surface, the gradient will be normal to this surface (Q: Why is the gradient normal?) - then all you want to do with your mesh is to compute its vertices' unit normals.

Using this wording, you should find plenty of methods to do so. For instance, here is a simple algorithm described by Perlin here:

  1. Initialize all the vertex normals to the null vector. In the next step, you're going to gradually accumulate values into these vectors.

  2. Loop through all the faces of your mesh. For each face, consider all pairs of successive edges around the face. For example, if your face has vertices A,B,C,D, in that order, then you would consider the four pairs of successive edges:

    • A→B and B→C
    • B→C and C→D
    • C→D and D→A
    • D→A and A→B

    For each pair of successive edges $e_1$ and $e_2$, take the cross product $e_1 × e_2$. Add the resulting vector to the normal of every vertex that adjoins the face (for example, in this case you would add to the normals of vertices A,B,C,D).

  3. Loop through all the vertices, and normalize the length of the normal vector of each one.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .