.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Internal angles of a polyline

2 REPLIES 2
Reply
Message 1 of 3
ccalvo12
1412 Views, 2 Replies

Internal angles of a polyline

Hi:

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)
                    vangl.Add(anguloM)
                Else
                    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)
                    vangl.Add(anguloM)
                End If

            Next
            Return vangl
        End Function

 

 

2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: ccalvo12

Hello,

 

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

http://forums.autodesk.com/t5/NET/Get-angle-between-LineSegments-polyline/m-p/3568906/highlight/true...

 

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

 

I also have a more complicated way to solve this problem 🙂

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.

 

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
ccalvo12
in reply to: Balaji_Ram

Hello:

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

 

Greetings

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost