Hello,
I'm still new to vb.net and can t manage to sort a list of points according to the distance to them. The following code gives me the first closest point (but later on i would like to be able to find more then one closest point). The array part was just an attempt in getting the list sorted... but without a result:
Private Sub RunScript(ByVal inPts As List(Of On3dPoint), ByVal sPts2 As On3dPoint, ByRef A As Object)
Dim d1 As Double = Double.MaxValue
Dim min1 As Int32 = -1
Dim d As Double
Dim arrS As New ArrayList()
Dim arrS0 As New List(Of List(Of on3dPoint))
Dim arrS1 As New List(Of Double)
Dim sList As New List(Of On3dPoint)
//the last 4 lines were to check different options
For i As Int32 = 1 To inPts.Count() - 1
d = sPts2.DistanceTo(inPts(i))
If (d < d1) Then
d1 = d
min1 = i
End If
Next
arrS0.Add(inPts)
arrS1.Add(d)
arrS.Add(arrS0)
arrS.Add(arrS1)
sList = arrS.Sort(inPts)
//the last 5 lines were to check different options
A = inPts(min1)
I would appreciate any kind of hint/help on this one,
Thanks in advance,
Tudor
Tags: