Create a Polygon with no Intersecting Lines
Hello!
Today I would like to learn how to create a polygon without any intersecting lines. How can this be done?
Thanks.
This is something I just wrote to create any random polygon.
vb Code:
Private Sub CreatePolygon(ByRef Color As Color, ByRef LocationBounds As Rectangle, Optional ByRef NumberOfPoints As Int32 = 10)
Dim R As New Random
Dim PolygonPointsList As New List(Of Point)
Dim PolygonArray() As Point
Dim G1 As Graphics = Me.CreateGraphics
Dim Sb As New SolidBrush(Color)
For i As Int32 = 1 To NumberOfPoints Step 1
Dim NewPt As New Point(CInt(R.Next(LocationBounds.X, LocationBounds.X + LocationBounds.Width)), _
CInt(R.Next(LocationBounds.Y, LocationBounds.Y + LocationBounds.Height)))
PolygonPointsList.Add(NewPt)
Next
PolygonArray = PolygonPointsList.ToArray
Me.Refresh()
G1.FillPolygon(Sb, PolygonArray)
End Sub
Re: Create a Polygon with no Intersecting Lines
If the lines don't intersect, they are parallel. If the lines are parallel, they are by definition not a polygon... by its very definition a polygon has to have intersecting lines. Otherwise you just have a bunch of lines that are meaningless.
-tg
Re: Create a Polygon with no Intersecting Lines
@NinjaNic
You mean a polygon whose lines only meet at the vertices?
Re: Create a Polygon with no Intersecting Lines
I have a random polygon creator in the codebank:
http://www.vbforums.com/showthread.p...hlight=polygon
I remember needing it for an asteroid game that I never finished.