turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Close

.NET

- Autodesk Community
- >
- AutoCAD Customization
- >
- .NET
- >
- Re: how to get the normalvector of a closed pline ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page

New Member

1 Posts

0 Kudos

Registered:
01-29-2008

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

303 Views, 8 Replies

06-15-2012 02:21 AM

hi,

we develop a cam-function with c-sharp and like to get the turningdirection of a closed pline with arcs. As arcs can "overtake" points things are getting a bit difficult. Is there a way to read the normalvector of a closed pline?

thanks for help,

Stefan

*Expert Elite*

1,569 Posts

171 Kudos

Registered:
10-08-2008

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-15-2012 04:30 AM in reply to:
kaufmann

Do you mean:

Vector3d vec=pline.Normal;

~'J'~

_____________________________________

C6309D9E0751D165D0934D0621DFF27919

C6309D9E0751D165D0934D0621DFF27919

*Expert Elite*

753 Posts

54 Kudos

Registered:
02-13-2008

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-15-2012 08:48 AM in reply to:
kaufmann

I'm not sure what you mean by arcs "overtake" points, but I think what you are trying to do is find the "Winding" of the polyline. You just traverse the polyline, getting each segment, and add up the angles between each adjacent segment (or the Start tangent and end tangent of the arcs). The result should come out to 2 Pi or -2 Pi, telling you whether the polyline runs CounterClockwise or Clockwise, respectively.

Dave O.

Member

3 Posts

0 Kudos

Registered:
06-20-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-20-2012 03:14 AM in reply to:
chiefbraincloud

Thank you for the answers!

Hallex wrote:Do you mean:

Vector3d vec=pline.Normal;In fact I need a function to get the orientation (clockwise or counterclockwise) of a polyline with respect to the xy-plane. In other cad-programs (e.g. Rhino) you can check the z-coordinate of the normalvector (positive or negative) to get the orientation but in AutoCAD this z-coordinate seems to be always positive.

Is there any build-in AutoCAD function to get the orientation of a curve?

chiefbraincloud wrote:You just traverse the polyline, getting each segment, and add up the angles between each adjacent segment (or the Start tangent and end tangent of the arcs). The result should come out to 2 Pi or -2 Pi, telling you whether the polyline runs CounterClockwise or Clockwise, respectively.

I already found this algorithm but it doesn't work in particular cases. Maybe you can give me some advice.

Problem 1:

When the polyline contains an arcsegment with an angle greater than Pi the orientation is fliped or the angle sum is zero. e.g.:

I solved this problem by dividing this arcs:

Problem 2:

I don't know how to handle parallel tangents with opposite directions. e.g.:

Distinguished Mentor

582 Posts

91 Kudos

Registered:
04-11-2010

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-20-2012 12:56 PM in reply to:
schwungrad

Hi,

It's very easy to check if a closed polyline is ccw or cw, you need to check what it's called the signed area of a polygon, check this link: http://demonstrations.wolfram.com/SignedAreaOfAPol

Gaston Nunez

Member

3 Posts

0 Kudos

Registered:
06-20-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-20-2012 10:57 PM in reply to:
kaufmann

For linear plines is very easy to find the orientation with the signed area.

But how I handle arc segments?

Moderator

1,465 Posts

277 Kudos

Registered:
04-09-2008

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-21-2012 12:33 AM in reply to:
schwungrad

*Expert Elite*

753 Posts

54 Kudos

Registered:
02-13-2008

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

06-21-2012 08:47 AM in reply to:
schwungrad

I was too busy yesterday to try my function against your two examples, I might have some time this afternoon, but I think you have done something wrong with the first example. You should be getting -270 for the arc which makes the sum -360. I'm pretty sure my routine would get that one right, but my routine would never see a polyline that looks like that.

Your second example is intriguing, but certainly nothing I would expect to see in my routine. My routine has a specific purpose, and that example is an impossibility for that purpose.

Edit: For that matter, you said your routine was a Cam function, right? Doesn't that mean you also would not see a polyline that looks like that? That's a pretty abrupt cam if you would.

Dave O.

Member

3 Posts

0 Kudos

Registered:
06-20-2012

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

07-05-2012 05:29 AM in reply to:
chiefbraincloud

We use polylines to define the movement of our fabrication tools so the algorithm should handle every closed LWPolyline with no self intersections.

As I used only the tangent vectors for my calculation I will always get the smaller angle = +90° (mathematical equal to -270°). Therefore I divided every arc which is larger than pi (so also the angles are always smaller than pi).

Of corse it is easier to use the opening angle (EndAngle - StartAngle) to calculate the change of direction of the arc.

For the seccond problem I simply check if the end point of the arc is on the left or on the right side of the previous end tangent.

My new algorithm seems to works with any kind of polyline (linear and with arcs).

Search This Board

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Post to the Community

Have questions about Autodesk products? Ask the community.

The Knowledge Network

Access a broad range of knowledge to help get the most out of your products and services.

Download & Installation

Getting your Software

Downloads & Upgrades

Serial Numbers & Product Keys

Installation & Licensing

Activation & Registration

Network License Administration

Subscription Management

Sign In / Create Account

Maintenance Subscription Help

Desktop Subscription Help

Cloud Service Subscription FAQ

Announcements

Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!

- Privacy | Legal Notices & Trademarks | Report Noncompliance | Site map | © Copyright 2014 Autodesk Inc. All rights reserved

Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see the Autodesk Creative Commons FAQ for more information.