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
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
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
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.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register