Posts: 11
Registered: ‎04-19-2012
Message 1 of 3 (448 Views)

Internal angles of a polyline

448 Views, 2 Replies
02-26-2013 09:37 AM


I have created the following code in VB.NET that i allows you to
calculate the internal angle of a polyline. First delivery getting the angle of
deflection, a ves obtained 180 you rest this and get the inner corner. All fine, as long as the polyline is the image-1.png. Otherwise, if the polyline is as in the image-2.png there is an error in the
vertex B.


That algorithm could follow in order to comply with the correct value. Since
later this data i presented it in a table of AutoCAD.


thanks for your help.


Public Shared Function AngleDeflection(ByVal pto3d As Point3dCollection) As ArrayList
            Dim anguloM As Double = 0
            Dim vangl As ArrayList = New ArrayList
            For i As Integer = 0 To pto3d.Count - 2
                Dim V As Integer = pto3d.Count - 2
                If i = 0 Then
                    anguloM = Math.Atan2(pto3d.Item(i).Y - pto3d.Item(V).Y, pto3d.Item(i).X - pto3d.Item(V).X) - Math.Atan2(pto3d.Item(i + 1).Y - pto3d.Item(i).Y, pto3d.Item(i + 1).X - pto3d.Item(i).X)
                    anguloM = Math.Atan2(pto3d.Item((i - 1) + 1).Y - pto3d.Item(i - 1).Y, pto3d.Item((i - 1) + 1).X - pto3d.Item(i - 1).X) - Math.Atan2(pto3d.Item((i - 1) + 2).Y - pto3d.Item((i - 1) + 1).Y, pto3d.Item((i - 1) + 2).X - pto3d.Item((i - 1) + 1).X)
                End If

            Return vangl
        End Function



ADN Support Specialist
Posts: 715
Registered: ‎03-21-2011
Message 2 of 3 (387 Views)

Re: Internal angles of a polyline

02-28-2013 11:35 AM in reply to: ccalvo12



Here is a thread that might give you some ideas to solve the issue :



I havent tried the code that Gilles Chanteau has suggested in that thread.


I also have a more complicated way to solve this problem :smileyhappy:

It works for both the kind of closed polylines that you have mentioned about.


The idea is the almost the same as Gilles suggests. Use the "GetAngleTo" method to determine the angle which will always lie between 0 and PI. But there is also an additional check to see if that angle is an interior angle of the closed polyline.


I have attached the source code in case you wish to try.






Developer Technical Services
Autodesk Developer Network

Posts: 11
Registered: ‎04-19-2012
Message 3 of 3 (361 Views)

Re: Internal angles of a polyline

03-01-2013 07:42 AM in reply to: Balaji_Ram


thank you very much for the reply, I reviewed the code and definitely is going to help me in solving the problem.



Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.