So to make it simple. I currently use a method I found online to compute the gradient of a scalar field of a mesh.

To test how accurate this is, I made a sphere and followed the gradient direction of the geodesic field to construct a line. That is to say, pick $p$ on the sphere and define $\phi(X)$ the function that return the geodesic distance between $X$ and $p$.

By a property of the exponential map described by Manfredo Do Carmo, the geodesic gradient (the tangent) at $X$ uniquely describes the geodesic containing both $X$ and $P$.

In short, if you know the correct tangent at $X$ you can just follow that direction in the exponential map and eventually hit the source $p$.

So I went and coded exactly that:

enter image description here

In that image, the source $p$ is at the intersection of the 3 lines in the bottom part of the image. So my line passes very close to it, but it doesn't hit.

My assumption is, this happens because my gradient approximation is quite linearly based and as such even small errors quickly have big effects, especially as the points grow farther apart.

I am wondering if people know of methods or algorithms that can improve the accuracy of the gradient.

I got the formula for the discrete gradient at page 28 here.

  • $\begingroup$ Just a guess off the top of my head, but I wonder if it would help to slerp the gradients instead of lerp? $\endgroup$ – Nathan Reed Sep 18 at 16:30
  • $\begingroup$ That may work well on spheres, but this should work on arbitrary meshes. In fact this entire thing is trying to generalize lerping to arbitrary meshes : p $\endgroup$ – Makogan Sep 18 at 16:41
  • $\begingroup$ I think that slerping might help for arbitrary meshes as well. $\endgroup$ – Nathan Reed Sep 18 at 16:48
  • $\begingroup$ How? I thought slerping isn;t really affine. By that I mean that if I offset my mesh theresults I would get would be different. $\endgroup$ – Makogan Sep 18 at 16:52
  • $\begingroup$ I'm imagining that when you interpolate a gradient vector along a triangle edge you do slerp(gradient1, gradient2, t) instead of lerp(gradient1, gradient2, t). It's just a different interpolation function that's sensitive to the angle between the gradients. It doesn't depend on absolute position or orientation of the gradients or the triangle. $\endgroup$ – Nathan Reed Sep 18 at 17:05

I dont know what you are using to calculate the Cotan, the accuracy should different on the implementation.

But you could do more accurate calculations yourself by approximating the values using taylor expansions.

Or find some other librar that can do it more accurate.

Also, make sure you are using high prec datatypes.

| improve this answer | |
  • $\begingroup$ This is not a problem of fp precission, it comes from using a linear approximation, as the aproximated gradient won;t be equal to the true gradient, regardless of fp precision. $\endgroup$ – Makogan Sep 17 at 1:37

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.