Hi guys,

At the moment I am imlementing the DENCLUE clustering algorithm and by that I generate a 3D mesh, made of small tiles, each having 4 vertices. I already keep all the tiles’ vertices in 200x200 matrix (array of arrays). The thing is, now I have to find a way how to calculate the peaks of the mesh. I have already found the peaks that are consisting only one tile at the top (this is when the tile on the left, right, forward, backward, and the ones on the each corner are less than the current tile). These are the white colored peaks. My problem is how to approach when some peak is consisting of more tiles with the same height, like the circled ones on the picture.

I hope you understand it, if not please ask me more specific questions.

Thank you in advance!!

Actually I found a way to iterate over all the points by recursion.

In case the current tile is having other tiles with the same height, by recursion I continue to search overthere if that point is a peak, and so on and so on. In the end all the points that are peaks are returned.

This is the code:

```
private void ReturnPeaks()
{
for(int p=0; p<200;p++)
{
for(int r=0; r<200; r++)
{
if(verticesMaximumMatrix[p][r].y>0)
{
List<Vector3> plateauList = new List<Vector3>();
plateauList.Add(verticesMaximumMatrix[p][r]);
bool tileIsPeak = IterateAround(plateauList, p, r);
isPeak[p][r] = tileIsPeak;
}
}
}
}
bool IterateAround(List<Vector3> plateauList, int p, int r)
{
bool tileIsPeak = true;
for(int i = p-1; i<p+2; i++)
{
for(int j=r-1; j<r+2; j++)
{
//continue if the tile already exists, so it doesnt go in ednless loop
if (plateauList.Contains(verticesMaximumMatrix*[j])) continue;*
```

*//return false if the actual tile is higher than the current tile*

*if(verticesMaximumMatrix*[j].y > verticesMaximumMatrix[p][r].y)**

*{*

*isPeak[p][r] = false;*

*return false;*

*}*

*else if(verticesMaximumMatrix*[j].y < verticesMaximumMatrix[p][r].y)**

*{*

*tileIsPeak = true;*

*}*

*else if(verticesMaximumMatrix*[j].y == verticesMaximumMatrix[p][r].y)**

*{*

*plateauList.Add(verticesMaximumMatrix*[j]);**

*tileIsPeak = IterateAround(plateauList, i, j);*

*if(!tileIsPeak)*

*{*

*isPeak*[j] = false;**

*return false;*

*}*

*}*

*}*

*}*

*if(tileIsPeak)*

*{*

*isPeak[p][r] = true;*

*}*

*return tileIsPeak;*

*}*