<p>I dont know what you are using to calculate the Cotan, the accuracy should different on the implementation.</p>
<p>But you could do more accurate calculations yourself by approximating the values using taylor expansions.</p>
<p>Or find some other librar that can do it more accurate.</p>
<p>Also, make sure you are using high prec datatypes.</p>

CC BY-SA 4.0
2020-09-17T01:37:39.067Z
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.
Makogan
CC BY-SA 4.0
2020-09-17T01:18:11.827Z
2020-09-17T01:18:11.827Z
the1bird
<p>So to make it simple. I currently use a method I found online to compute the gradient of a scalar field of a mesh.</p>
<p>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 <span class="math-container">$p$</span> on the sphere and define <span class="math-container">$\phi(X)$</span> the function that return the geodesic distance between <span class="math-container">$X$</span> and <span class="math-container">$p$</span>.</p>
<p>By a property of the exponential map described by Manfredo Do Carmo, the geodesic gradient (the tangent) at <span class="math-container">$X$</span> uniquely describes the geodesic containing both <span class="math-container">$X$</span> and <span class="math-container">$P$</span>.</p>
<p>In short, if you know the correct tangent at <span class="math-container">$X$</span> you can just follow that direction in the exponential map and eventually hit the source <span class="math-container">$p$</span>.</p>
<p>So I went and coded exactly that:</p>
<p><a href="https://i.sstatic.net/4BaIL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4BaIL.png" alt="enter image description here" /></a></p>
<p>In that image, the source <span class="math-container">$p$</span> 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.</p>
<p>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.</p>
<p>I am wondering  if people know of methods or algorithms that can improve the accuracy of the gradient.</p>
<p>I got the formula for the discrete gradient at page 28 <a href="http://www.hao-li.com/cs599-ss2015/slides/Lecture04.1.pdf" rel="nofollow noreferrer">here</a>.</p>

CC BY-SA 4.0
2020-09-18T16:30:57.153Z
Just a guess off the top of my head, but I wonder if it would help to slerp the gradients instead of lerp?
Nathan Reed
CC BY-SA 4.0
2020-09-18T16:41:54.103Z
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
Makogan
CC BY-SA 4.0
2020-09-18T16:48:04.110Z
I think that slerping might help for arbitrary meshes as well.
Nathan Reed
CC BY-SA 4.0
2020-09-18T16:52:40.887Z
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.
Makogan
CC BY-SA 4.0
2020-09-18T17:05:41.133Z
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.
Nathan Reed
CC BY-SA 4.0
2020-09-18T20:15:20.270Z
Imma try it just to see if it makes a difference
Makogan
CC BY-SA 4.0
2021-06-15T08:45:02.877Z
Here is an interesting blog on forward/central/diagonal differences https://bartwronski.com/2021/02/28/computing-gradients-on-grids-forward-central-and-diagonal-differences/
pmw1234
<mathematics><computational-geometry><geometry><gradient><differential>
Improve accuracy of mesh gradient?
Makogan
# Improve accuracy of mesh gradient?

(Asked by: username_0 on 2020-09-17)

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](https://i.sstatic.net/4BaIL.png)](https://i.sstatic.net/4BaIL.png)

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](http://www.hao-li.com/cs599-ss2015/slides/Lecture04.1.pdf).

**Tags:** mathematics, computational-geometry, geometry, gradient, differential

> **Comments:**
> **username_1**: Just a guess off the top of my head, but I wonder if it would help to slerp the gradients instead of lerp?  
> **username_0**: 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  
> **username_1**: I think that slerping might help for arbitrary meshes as well.  
> **username_0**: 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.  
> **username_1**: 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.  
> **username_0**: Imma try it just to see if it makes a difference  
> **username_2**: Here is an interesting blog on forward/central/diagonal differences https://bartwronski.com/2021/02/28/computing-gradients-on-grids-forward-central-and-diagonal-differences/  

---

## 1 answers

### Answer by username_3 on 2020-09-17. Score: 1

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.

> **Comments:**
> **username_0**: 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.  

---

