I have a grid in terms of two arrays:

points: contains 3D coordinates of points.

triangles: contains 3 indices per line for each triangle of the grid.

I would like to interpolate the grid to make it smoother, i.e. add extra points and triangles in such a way that the grid is smoother than it is at the moment. But I found that scipy.interpolate only works if the xy-points are regular, which is not the case here. Any suggestions?


Measure each triangles square or non-smoothness, and if it is not small enough - then add a new vertex in its center (Centroid) and reaplace the triangle with 3 smaller trangles using that new vertex.

Update: Typically new Z value is an average between other Z values, just like with X and Y axis. If you have an underlying height map - take values from it. Afterwards you could apply a smoothing pass - measure curvature between polys in each vertex and shift it accordingly to decrease it.

  • \$\begingroup\$ I was thinking about using the centroids too. But what z-value do I give to the new vertex? \$\endgroup\$
    – John
    Apr 11 '17 at 20:51
  1. Create another array parallel to your points array to store normal vectors. Initialize it to zero vectors.

  2. For each triangle in your mesh, compute a triangle normal as the normalized cross product of two of its edges.

  3. Add this triangle normal to the normal array entries for each of the participating vertices.

  4. Once you've summed up all of the normals, re-normalize every normal in the array (averaging the effects where multiple triangles share a vertex).

  5. For each triangle, decompose it into additional triangles using this local curvature data as a guide. There are lots of different methods you could use here, for instance...

    • For each edge of the triangle, from each vertex in that edge, calculate a vector in that vertex's local tangent plane (perpendicular to the vertex normal) that points toward the opposite end of the edge.

    • With these two endpoints and tangent vectors, compute an interpolated point halfway between, using your favourite spline formula.

    • Connect the three new edge-bisecting points formed this way to split the original triangle into 4, in a triforce pattern.


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.