Connecting rotated points based on previous connected point

Hi,

I’m having a problem on how to create a logic through grasshopper connecting points based on rotation.
Basically, the logic would be shifting each point clockwise to connect to the top layer points. It gets tricky where there is not an available point and has to skip the grid point in order to reach the next available point. I hope the image below explains what I mean.

Though this is 2d, in reality, it will be 2 layers where point A connects to B in the Z direction.
In the attached file I drew manually how it should be in each step but eventually, all points should be connected in a single given surface. (each step is to explain the process)
I hope there would be a solution to this.

Thanks,

P.S the black dots in the 2D image represent points that are on a surface and the grid is based on a boundary box of the surface. Only the points on the surface count which you can see in the Rhino file. The attached grasshopper file contains the Cull out of Brep points that are on the surface.

rotating points.gh (39.6 KB)
ROTATION EXPLANATION.3dm (4.0 MB)