# Align vectors from closed planar curves

Hello,
I am facing a weird problem. I have a set of planer curves which are rebuilt curves from a mesh body, they have different vectors at different points(parameters). Marked in green are the problem vectors.

If you increase the frame count you will see that all these curves have problems. Does anyone have a solution?

Curve vectors align.gh (23.1 KB)

there are for sure many ways to correct this, all is needed is to flip the curves whose vector is pointing in the wrong direction (the ones circled in green in your screenshot)

but because those curves come as sections between a mesh and planes, my best suggestion is not to correct the definition at this point, but to make small changes earlier, where those curves are created
I say this because of the data structure, and also because it might be as easy as somehow switching a Boolean

All these curves are closed and somehow every single curve has two vectors (supper strange). I assume they have a torsion in them, which I need to solve.

You can see it here.

Hello, I have no idea what those arrows represent. Can you describe what they are?

I think Iβm not really understanding what you are after in particular, Iβm not understanding what you are trying to measure using the perpendicular frames

The white arrows represent the twist in the curve which should not be present and because of this, the vectors flip at different parameters ( in red arrows).

I need the frame vectors to align correctly so that the z coordinates are correct in machines G code.

So, itβs easy. Those curves do not have twist (I would say torsion). So whether the arrows poiting to the right or left is ambiguous.

You can take the βXβ and βYβ and put them into a CrossProduct component to get an aligned βZβ.

Is there a way to fix the Torsion?

The curves are planar, meaning the torsion is zero. That third arrow (Z component of the frame) is supposed to be pointing to the direction the curve twists towards. So, tere is no way to fix it. Just take the βXβ and βYβ of the frame and construct βZβ from scratch using the CrossProduct component.

Is there a way to separate the wrong vectors using pick and choose?

Try this

Curve vectors align 2.gh (40.1 KB)

1 Like

Thank you, It solved the problem.