Orientation Curve No Closed


I´m programming a project with C# and rhinho

I want to know the orientation of a curve when this curve is not closed.

Thank you.

When you have a Curve object, you can ask for PointAtStart and PointAtEnd.
This can give an idea of the orientation of the curve.

Also, you can ask for TangentAt(t) where t is in the curve domain. This is a tangent vector that is oriented “in the direction of the curve”.

Curve crv;
Point3d startPoint = crv.PointAtStart;
Point3d endPoint = crv.PointAtEnd;

double t = crv.Domain.Mid;
Vector3d midCurveTangent = crv.TangentAt(t);

Can I know if the orientation is Clockwise or CounterClockwise?

When the curve is closed I use this:

CurveOrientation orientation = curva.ClosedCurveOrientation(plano);
if (orientation == CurveOrientation.Clockwise)

No. You could temporarily close the curve if that makes any sense in your case.

Curve open; // defined elsewhere
PolyCurve closed = new PolyCurve();
closed.Append(new LineCurve(closed.PointAtEnd, closed.PointAtStart));
CurveOrientation o = closed.ClosedCurveOrientation(plano);


I’ve the same problem, but I want to get the orientation of line.

I’ve modify the menno algotirhm adding a intermide line, else I can’t get the orientation

        Curve open = (Curve)curva.Duplicate(); // defined elsewhere

PolyCurve closed = new PolyCurve();
            Point3d ptoIntermedio = closed.PointAtEnd;
            ptoIntermedio.Z += 5;
            closed.Append(new LineCurve(closed.PointAtEnd, ptoIntermedio));
            closed.Append(new LineCurve(ptoIntermedio, closed.PointAtStart));
            closed.TryGetPlane(out plano);
            CurveOrientation orientacionCurva = closed.ClosedCurveOrientation(plano);

if ( orientacionCurva != orientacion)

But the code is ugly… there is a better algotirhm to set the orientation?

A line does not have a clockwise/counter-clockwise orientation. But a line does have a direction.

Rhino.Geometry.Vector3d dir = line.To - line.From;

You can compare this vector to whatever to determine its orientation…


I need the orientation because I want import from a dxf that contains lines and structure of model, and I’ve to build a model from this lines.

As the dxf only are curves, I always need set the same direction to obtain always the same point start and point end to build the model. If the direction is inverted the model isn’t built well

To see if two curves are “more or less traveling in the same direction”, use Curve.DoDirectionsMatch
Maybe it is useful?

See http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Curve_DoDirectionsMatch.htm