# Getting the distance between points by moving along the gradient

**URL:** https://discourse.vtk.org/t/getting-the-distance-between-points-by-moving-along-the-gradient/12542
**Category:** Support
**Created:** [October 26, 2023, 7:34am UTC](https://discourse.vtk.org/t/getting-the-distance-between-points-by-moving-along-the-gradient/12542 "2023-10-26T07:34:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![maksim\_dzhigil](https://discourse.vtk.org/user_avatar/discourse.vtk.org/maksim_dzhigil/32/7699_2.png) [@maksim\_dzhigil](https://discourse.vtk.org/u/maksim_dzhigil)
#### Post date: [October 26, 2023, 7:34am UTC](https://discourse.vtk.org/t/getting-the-distance-between-points-by-moving-along-the-gradient/12542/1 "2023-10-26T07:34:22Z")

</div>

I have a model of the human heart represented by a surface mesh. I solve the Laplace differential equation to calculate the wall thickness on this domain. The solution is saved in vtu format and is a volumetric mesh. Below is an example of slice of the heart with the equation solved (with 16-color discretisation).

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/ffd6074e36aa309dfc3b47c63b8695d033086abf.png)

Here’s also an explanation of why you should use the Laplace equation to calculate heart wall thickness.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/91741199f12b76a66bfed003029ae668ce13317b.jpeg)  
A - calculation through the normal to the surface  
B - calculation through KDTree  
C - calculation through Laplace’s equation

My question is how to get the distance between two points given the gradient (Laplace’s equation solution). My idea is to take a 0.5 level isoline (the middle of the heart wall) and use something like gradient descent to find intersections with each of the walls. Then the sum of the lengths of the vectors will be the length of the heart wall. How can I use vtk to solve this? Is there a simpler solution?
