No wonder it looked familiar. I seriously need sleep.
Eerie. Too eerie.
I registered just to reply to your post. I will post again if I figure it out before you do . Meanwhile, check out this [V][C]- scratchbuilt for the same issue, straight from my current project:
Public Function RadialSort(ByVal GPSPointCollection As Collection, ByVal Bounds As RectangleF, ByVal GraphicsObject As Graphics, Optional ByVal SweepResolution As Integer = 1, Optional ByVal CloseFigure As Boolean = True) As PointF()
'On Error Resume Next 'TODO: This is crap
If GraphicsObject Is Nothing Then Return Nothing
Dim oPoint As New Point
Dim oFirstPoint As New Point
Dim oGPS As New seGpsPoint
Dim oColl As New Collection
Dim oTemp As New Collection 'Collection of Points already captured
Dim CenterPt As New Point
Dim oMatrix As New System.Drawing.Drawing2D.Matrix
Dim iAngle As Integer = 0
'Set Sweep Centerpoint
CenterPt.X = CInt(Bounds.X + Bounds.Width / 2)
CenterPt.Y = CInt(Bounds.Y + Bounds.Height / 2)
Dim oSweepRect As New RectangleF
'Define Sweep Arm rectangle
oSweepRect.Y = CenterPt.Y
'Conservatively define Sweep Arm
oSweepRect.Width = Convert.ToSingle(Math.Max(10, Bounds.Width / 20))
oSweepRect.X = (CenterPt.X - oSweepRect.Width / 2)
'Trig to make sure all points are in Sweep Radius
oSweepRect.Height = Convert.ToSingle(Math.Sqrt(((Bounds.Height / 2) ^ 2 + (Bounds.Width / 2) ^ 2))) + 10
Dim oSweepRegion As New Region(oSweepRect)
'Collection of seGpsPoint Objects, each with a PointF
oColl = GPSPointCollection
'Target PointF Array to be returned length = Collection Count
Dim aryPoints(oColl.Count) As PointF
If Not CloseFigure Then
ReDim aryPoints(oColl.Count - 1)
End If
Dim iCtr As Integer = 0
Dim iIndex As Integer = 0
'Define rotation as [SweepResolution] degrees
oMatrix.RotateAt(SweepResolution, CenterPt)
GraphicsObject.FillRegion(Brushes.Transparent, oSweepRegion)
'Make sure all 360 degrees are covered
For iAngle = 0 To 361
'This will rotate the system.drawing.drawing2d.matrix by 1 degree
oSweepRegion.Transform(oMatrix)
GraphicsObject.FillRegion(Brushes.Transparent, oSweepRegion)
Dim aryArm() As RectangleF = oSweepRegion.GetRegionScans(oMatrix)
'This is a processor intensive bit
For iIndex = 0 To aryArm.Length - 1
For Each oGPS In GPSPointCollection
If aryArm(iIndex).Contains(oGPS.DrawingPoint) Then
Dim strKey As String
strKey = oGPS.GpsID.ToString
'Don't duplicate points, in case arms overlap on this iteration
If Not oTemp.Contains(strKey) Then
'Add seGpsPoint object and key to 'already captured' Collection
oTemp.Add(oGPS, oGPS.GpsID.ToString)
aryPoints(iCtr) = oGPS.DrawingPoint
'Increment array index when new point is captured
iCtr += 1
If iCtr = oColl.Count Then
'Set Last Point to FirstPoint to for Closed Figure
If CloseFigure Then
aryPoints(iCtr) = aryPoints(0)
End If
'Commit array and exit when array is full
Return aryPoints
'RadialSort = aryPoints
Exit Function
End If
End If
End If
Next
Next
Next
'This code should never be executed if all is well:
RadialSort = aryPoints
End Function