Curve.ClosedCurveOrientation(...) gives different result in Rhino6 compared to Rhino5

I have the same curve in Rhino5 and Rhino6.
In Rhino5 I get correct result (if compared to what I see also in Rhino when performing Analyze Direction),
in Rhino6 i get the opposite (and apparently wrong) result.
Is that a bug in Rhino6? Something changed?

Hi Donation,

For efficient answers, can you provide an example file with curves exhibiting this behavior?
Possibly with example code to test

-Willem

CurveDirectionTEST-RH5.3dm (27.3 KB)

CurveDirectionTEST-RH6.3dm (41.5 KB)

The first one is on Rhino 5, the second one is on Rhino 6.
When viewing the curves (each on the respective Rhino version) , and select Analyze -> Direction, I see the same direction (clockwise when looking towards the same direction of the Y axis), on both Rhino5 and Rhino6.

But, calling the function Curve.ClosedCurveOrientation(…) (using a vector parallel to the Y axis, or a plane with the normal parallel to the Y axis), I get opposite responses
Rhino5 --> clockwise (expected)
Rhino6 --> counterclockwise (wrong?)

(using Rhinocommon library on C#)

NOTE:
I found this problem when porting my plugin from Rhino5 to Rhino6.

Hi @donato1,

Your curves are counter-clockwise with respect to the world y-axis (0, 1, 0).

The Rhino 5 calculation is incorrect.

https://mcneel.myjetbrains.com/youtrack/issue/RH-32952

– Dale

Hi Dale, thank you very much for your response, very useful!

I’m in the situation to continue to support my plugin in both Rhino5 and Rhino6, so, I guess that it should be sufficient to reverse the Rhino5 response to have them coerent. Whatever the curve is.
Can you confirm this?

Thanks.

Hi @donato1,

No, it’s not sufficient to just flip the results.

In Rhino 5, you will want to use the Curve.ClosedCurveOrientation override that accepts a Transform as a parameter.

For example:

import Rhino.Geometry as geo
import rhinoscriptsyntax as rs

curve_id = rs.GetObject("Select curve", rs.filter.curve)
curve = rs.coercecurve(curve_id)

# The target plane to test against
origin = geo.Point3d.Origin
xaxis = geo.Vector3d.XAxis
yaxis = geo.Vector3d.ZAxis
plane = geo.Plane(origin, xaxis, yaxis)

# Transformation to map the curve to the world xy plane
xform = geo.Transform.PlaneToPlane(plane, geo.Plane.WorldXY)

# Do curve calculation
print curve.ClosedCurveOrientation(xform)

– Dale

Thank you very much.
Your informations are precious.