Flip Curve Not Adhering To Guide Curve?

I’m flipping curves enmasse, but here the guide curve doesn’t flip all of the offsets in the same direction.

The script has Wombat components for visualisation, but you can also inspect it with the added Point on Curve components.
Flip curves malfunction.gh (125.3 KB)

Version 8 SR31
(8.31.26126.13431, 2026-05-06)

Hi Intuos,

The Guide input isn’t evaluated locally, only the vector between its end points matters (and for closed curves, its orientation), so on a zig-zag like this it can’t keep every offset aligned — some of those chords end up near perpendicular to the guide’s. David covers it here.. Flip with guide curve fails - #5 by DavidRutten RadovanG’s C# in that same thread compares tangents at the closest points instead, which is what you’re after.

The C# component does not work on these curves and your explanation does not makes sense to me. If it is just comparing the start to end vector of the guide curve to the start to end vector of the curves, why is it failing?

Flip curves malfunction VR.gh (134.5 KB)

I’ll look into more, my explanation was gathered from David’s answer on the thread, it’s not something i actually know much about, only that it didn’t work quite like people expected.

Ok, The component has an ‘if’ statement. David’s answer describes what Flip Curve does when the guide is linear. Guide not linear → fit a plane to the curve and to the guide, then
compare the clockwise-ness of their control polygons in those planes.

Creating a linear guide like this works for these curves.

On RadovanG’s C#, you’re right there too. Its rule is the angle between tangents at the mutually closest points, and on these curves three of those four angles land at 83.7 / 97.3 / 97.3 degrees right on the 90° boundary, because the closest point between an offset and a zig-zag guide falls where the two run across each other. Comparing near perpendicular tangents is a cointoss, so it flips three of the four the wrong way.

Thank you for looking into it and explaining… I am not sure I understand:

The algorithm takes the controlpoint polygon projected onto an averaged plane and measures the righthandedness of the corners versus the lefthandedness and sees which is majority; is that about the gist of it?

Flip Curve really should have a boolean input for flipping curves by a mask instead of a guide as an option.

Here is the clockwise calc..

        pa = CurvePlane(curve);  pb = CurvePlane(guide)           // plane fitted to each
        par = pa.ZAxis.IsParallelTo(pb.ZAxis, pi/4)
        par ==  1 -> flip if IsClockwise(curveCtrlPolygon, pa) != IsClockwise(guideCtrlPolygon, pb)
        par == -1 -> flip if the two clockwise senses are EQUAL   // mirrored frame
        par ==  0 -> warning "Guide and curve are not roughly co-planar,
                     flipping may be unpredictable." + IsAligned(curve, guide)

GH2 does behave differently, end to end vector or ClosedCurveOrientation, the clockwise aspect was removed.

Okay, that makes sense in this case, because the start to end point vector is the only thing i thought flip curve checked for. And if it only checked for this vector, then the curves should be all be in the same direction.
Any chance the component can be made more robust for GH1?