I have a pair of similar scanners from different manufacturers. The task relates to 2D (so far away from 3D).
When data is requested, a packet (one-dimensional array) of ~ 1000 dimension comes, for each point, two values are the first X and the second Y.
EXAMPLE OF MASSIF (the view on the chart will be, a line with a small slope)
[25,354; 40,250; 25,599; 40,942; .......... 50,304; 42,231]
In the first case, you need to find the following point (in the picture marked with blue): 
But it should not be just a maximum of an array. In fact, these are 4 lines (from an array of points), the algorithm must unite the points in a line and, based on the number of lines found, look for something defined on them or in them (middle, gap between the first and second)
The parameters that can be changed in the algorithm are the half-width of the line (distance from noise to the calculated line), before the algorithm combines them in a line, it also looks at the maximum distance from a point to a point and decides whether to include it in a line or not.
I use the method of least squares, but it works only with straight lines. and that is not entirely correct. How to merge points into lines and then operate with lines? Because my algorithm works once out of a hundred.
example of the scanner on the link (tyk in me) !