3

This is easier explained with pictures. I have these green points:

Points (no line)

And I want to get a few points along this red line:

Points (with line)

This is a top view, but I have complete XYZ coordinates for each point. I also have which vertex is connected to which other vertex.

It almost seems like you could just take the midpoint of each of those green edges and draw a line through them but you can see how that wouldn't really work near the end.

Is there an algorithm I can use to find a line of best fit through these 3D points?

I'm using Three.js if that makes a difference.

xtofl
  • 40,723
  • 12
  • 105
  • 192
Sunjay Varma
  • 5,007
  • 6
  • 34
  • 51

1 Answers1

1

This task is equal to noise suppression. the simplest algorithm (end of array will not be filtered):

double array[];
int count, depth;
// 1 < depth < count

for (int i = 0; i < count - depth; i++)
{
    double sum = 0;
    for (int j = 0; j < depth; j++)
    {
        sum += array[i + j];
    }
    array[i] = sum / depth;
}

You can find more info googling Median Filter and Noise Suppression

Maksim
  • 367
  • 2
  • 11