1

I have a set of coordinates in a 3D system, the points are generated randomly. I've trying to order them based on their position in Room ,without any sign of enter image description heresuccess.

what I want to do is to get a order a way that looks more like a helix.

enter image description here

I've tried to order the X's,Y's and Z's to get the helix curve but the result was even worst, in the image you can see point Nr 29 in the wrong position!

can anyone here give me a hint about how can I order them. PS: the set of the points can changed for that I need to have a logic behind the order + I'm NOT asking for code!!

thanks in advance !

Engine
  • 5,360
  • 18
  • 84
  • 162

2 Answers2

1

Here is my suggestion. It is not perfect but you probably won't find a perfect solution for this problem:

Split the Z axis into a number of intervals, e.g. [0,4[, [4,8[, ...

First order the points by the interval to which their Z coordinate belongs.

Within each interval, sort by the angle of rotation around the Z axis, that can be calculated by atan2(Y,X) in most languages. Basically you are using cylindrical coordinates.

Frank Puffer
  • 8,135
  • 2
  • 20
  • 45
1
  1. coordinate system

    You did not specify which axis is which so for the following I assume the helix axis is parallel with Z axis which is pointing up in your helix diagram.

  2. sort the points by Z coordinate ascending

  3. Find helix axis

    This is tricky and depends on many things like is your helix skewed, are there noise points, how dense are the points distributed etc. The simplest way is obtain bounding box from all the points (or just local area) and the axis is in the middle of it. So if bounding box is (xmin,ymin,zmin,xmax,ymax,zmax) then the center axis would be line perpendicular to Z axis:

    x0=0.5*(xmin+xmax)
    y0=0.5*(ymin+ymax)
    z0=<zmin,zmax>
    

    If you need something more sophisticated see

  4. sort points by polar angle

    So process all points. find points with the same Z coordinate and compute their polar angle a around center (x0,y0)

    a(i)=atan2(y(i)-y0,x(i)-x0)
    

    Now sort them ascending or descending (depends on what output you need CW/CCW). When you sorted all the points per the same Z axis the whole set should be helix ordered.

    If your points are noisy then use close Z coordinate instead of the same. And may be add connected components analysis to adjust the order.

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380