rs.CurveDirectionsMatch issue


I’ve been writing a script that use python CurveDirectionsMatch function to align the curve directions and I ran into an issue - when I have co-linear lines then the above mentioned function always return true, regardless of the actual orientation…
see curves (1) on the attached picture. Find attached picture where I try to present the situation described

When the lines are not co-linear the function works as expected

I also made a test (2) : I split the smooth curve and intentionally flipped one part. function again returned true.
But when I misaligned the edges of the same curves (3) it returned false as it should

Is there an other way to compare curve directions without going deeper into vector math?

Only thing I have on my mind is to compare vectors at start point of each curve if it is less then 90 degrees…


Hi Aleksandre,

It is definitively a bug with Curve.DoDirectionsMatch method.

You can also use the Vector3d.IsParallelTo method with tolerance close to 90 degrees:

Hvala Djordje!

Thanks for the advice

I also needed a proof that I’m not overlooking something! :grinning: - because I used the DoDirectionsMatch from Rhinocommon many times before and never run into this…

I already made my own function based on calculating angle between the start point vectors that works sufficiently for me.


1 Like