# Extrusion Direction

Question:

Hi Dale,

source snippet
3DM file output of the code

The extrusion results in the opposite direction, that is in the -Z direction. Also when you rotate the model the end caps seem to have a bounding-polygon added along with the true endcap and this polygon is only visible from one direction.

Can you help me, please?extrude-bumbba.cs (2.5 KB) extrude-bumbba.3dm (125.3 KB)

Hi Reuben,

In the future, I’d appreciate it if you’d post these types of questions on the forum. I’m sure others would benefit from your question and answer.

First, a curve has a direction. And the plane of a closed planar curve is calculated from this, the tangent, direction.You can use Curve.ClosedCurveOrientation to determines the orientation (counterclockwise or clockwise) of a closed, planar curve in the world xy plane. You can also use Vector3d.IsParallelTo to compare the curve plane’s z-axis to the world z-axis.

Also, If you want to transform some from one coordinate system to another (e.g. from world xy-plane to construction plane or vise versa), then create a change of basis transformation - Transform.ChangeBasis. I doubt this is what you’re looking to do. Instead, use Transform.PlaneToPlane, which creates a rotation transformation that orients one plane to another plane.

– Dale

Thanks, Dale!

I copied the extrusion code from one of your examples and see what happens and it DID extrude after all but in a different direction but i shall try your suggestion and will get back to you in due course

First, a curve has a direction.
?? Sure a curve has A direction but it is at a given point on the curve, derivative of the curve (gradient) or are you talking in terms of NURBS representation? We are dealing with a closed curve, perhaps you mean, the orientation of the curve, i d ont know, i am from the polygon mesh era and am yet to digest Raaja Issa’s useful doc “essential math for computational geometry” or something like that!!

Thanks Dale, for your legendary patience with the newbies

Sorry Dale,

I still do not understand what I need to do/modify my code to work properly ?

isParallelTo would only reveal if it is parallel not whether if it is parallel or anti-parallel would it?

OK!

Dale’s suggestion to use fixed the dodgy end cap(bounding polygon that was visible only from one direction.

basically the closed curve, outer loop needs to have a clockwise orientation and inner loops to have counter clockwise orientation. fix that and the problem disappeared.

if (outerProfile.ClosedCurveOrientation(plane.ZAxis) != CurveOrientation.Clockwise) outerProfile.Reverse();

foreach (var profile in innerProfiles)
{
if (profile.ClosedCurveOrientation(plane.ZAxis) != CurveOrientation.CounterClockwise) profile.Reverse();
}