I’m generating some Curves in a c# / RhinoCommon Plug-in.
The curves are used for Extrusion.Create
I can t get the correct / expected side for the extrusion, and it seams it s the fault of the return Plane of the Curve…
I always thought, that a closed planar Curve is CCW orientated in it s (corresponding) Plane, the Plane returned by TryGetPlane.
Is this wrong ?
or is this a Bug.
If a planar Curve has a random Plane Orientation - then Extrusion.Create does not make sense - as it uses the Plane - and it will afford to correct the extruded direction / side.
Please:
should the Plane of a closed Planar Curve always be CCW ? yes / no ?
if No
please update the documentation of TryGetPlane
please add an overload to Extrusion.Create that allows a correct direction
With the exception of an ArcCurve, which is comprised of a plane and other properties, the plane of a Curve is computed as needed.
When computing a curve’s plane, the starting point is used for the plane origin, and the tangent direction at the starting point is used for the the plane’s x-axis. The plane’s y-axis is computed by evaluating curve spans.
So to answer your question, yes, the plane of a closed planar curve is always counter-clockwise to it’s computed plane, being that the plane is computed from the curve itself.
Of course, what appears to be counter-clockwise in one view projection can be considered clockwise in another.
I’ve attached a simple Python script to extrude the curves in your model.
but that does not seam right with “my” curves.
they both have the same shape and orientation, only different starting point.
so the result is an extrusion in two different directions.
…
ok I added a few lines of code to your test-Scripts (thanks) and this shows my missunderstanding:
by the way - can i be sure that all constructors of new Plane (...)
always ensure a proper unit-vector, right hand rule, 90-degree setting ?
(for a my_plane.IsValid == true )
I don’t know what your exact issue is. You are showing curves with different orientation, so planes and extrusions will be different. How are you creating the curves that they are sometimes CW and sometimes CCW?
thanks @Gijs
which version of rhino did you use to test ?
my problem (Mac Version 7 (7.30.23130.11002, 2023-05-10))
one of the curves returns a Plane (Curve.TryGetPlane) but within this plane the curve is CW instead of CCW - and this results in wrong direction of Extrusion.
what results are you getting when running above .py script.
( I get clockwise / counterClockwise - but expected counterClockWise twice)
Hi Tom, my best guess is that it is not so much a bug, but rather a limitation based on how the plane is being calculated. If I load it in GH, I see that the plane is flipping there as well. So I’d say, you need a workaround for this.
A planar curve does not determine the orientation of the plane.
orient.3dm (51.0 KB)
Only if the curve is closed and simple (no self intersections) does it uniquely determine an orientation. If it satisfies these conditions one can use curve.ClosedCurveOrientation(plane) to get the orientation with respect to the plane.
I don’t think all these steps should be included in curve.IsPlanar(plane) because they are going significantly beyond just determining if a curve is planar.
dear @GregArden
thanks for digging into this topic. It s clear that a self-intersecting curve is a special case…
What about the curves I posted at the beginning / top of this topic ?
My main concern is, that it looks like Extrusion.Create is using the orientation of the plane, given by the curve, to decide the extrusion direction - and it looks like there is some inconsistency (or bug).
Extrusion.Create takes a plane and a curve, each have their own orientation. According to the documentation of Extrusion.Create, I would expect the direction of the extrusion is relative to the plane orientation, i.e. it is independent of the curve orientation. Is this what happens? So the user must understand the plane orientation to get predictable results.
Geometry.Curve.TryGetPlane (which is basically ON_Curve::IsPlanar( ON_Plane*, double) in c++) does not guarantee an orientation of the plane. So you need to decide on the orientation before you make an extrusion. If you want to make that decision based on the orientation of the simple closed curve use Geometry.Curve.ClosedCurveOrientation(plane) to decide.
Tom,
I see that you’re right the RhinoCommon method Extrusion.Create only takes a curve. So I changed ON_Curve::IsPlanar(plane, tol) to get the compatible orientation for a simple planar closed curve. Now you can get predictable behavior from Extrusion.Create in this case.
This is even more of a problem for open planar curves since there is no cannonical orientation of the plane and as you point out the interpretation of the height parameter depends on the orientation of the plane. In this case I think Dale’s youtrack https://mcneel.myjetbrains.com/youtrack/issue/RH-75208 is the right solution.
most cases where developers will use Extrusion.Create also the curve was created by code and therefor this would be most robust, it is not a big deal to code the correct orientation.
And Yes Dale 's youtrack is the right solution - maybe Extrusion.Create without a plane / direction parameter is “promising” to much.