Accord.net KD-Tree ближайший сосед выпуск - PullRequest
0 голосов
/ 01 сентября 2018

Проблемы с ближайшим соседом в KD-дереве в рамках Accord.

У меня есть следующий код:

        Dim pointList As New List(Of Double())

    pointList.Add({1.46939327461431, 0.728514297626614, 0.611199911110152})
    pointList.Add({1.29616291008733, 0.715801752689344, 0.76567439368152})
    pointList.Add({1.21998918620861, 0.714409383988963, 0.624730329395141})
    pointList.Add({1.40033932275504, 0.837025245715406, 1.41604934632078})
    pointList.Add({1.30264996956905, 1.27968341310233, 1.27632592090544})
    pointList.Add({1.25685958475519, 0.789886517499592, 0.778997383833871})
    pointList.Add({0.764351117156931, 1.2470180631204, 1.08164987755654})
    pointList.Add({1.34663911274196, 1.44441179931612, 1.09005587026757})
    pointList.Add({0.869899807222235, 0.597165790809216, 0.675122144359106})
    pointList.Add({0.562320470292234, 1.33413629676582, 1.38153502250285})
    pointList.Add({0.97461478445286, 0.660162336721388, 1.09912310227134})
    pointList.Add({0.669855892884259, 1.27075839972262, 0.818628838025211})
    pointList.Add({0.764710954287365, 1.39133804754551, 1.11929873503679})
    pointList.Add({0.782382040627924, 1.21912260024516, 1.34580185198657})
    pointList.Add({1.36869464864441, 0.848445415993126, 1.22253001356577})
    pointList.Add({0.620546528532536, 1.22197895901718, 0.820606748519882})
    pointList.Add({1.17416007469763, 1.49776753070633, 0.532315387936957})
    pointList.Add({1.05021874503986, 1.21665051789072, 0.649302920270058})
    pointList.Add({1.09174472241809, 1.23229029263019, 0.916774281520864})
    pointList.Add({1.45883823612704, 1.0997149335696, 1.35632498089295})
    pointList.Add({2.97155494008615, 3.01953923740247, 2.70901488969513})
    pointList.Add({3.11206042666745, 2.64570926816952, 2.93426987723382})
    pointList.Add({2.69997433997831, 3.21066411895657, 2.65891902388905})
    pointList.Add({3.36155274149625, 3.14215415932562, 3.35617956399353})
    pointList.Add({3.05323570716861, 3.39666004066799, 2.56521646117696})
    pointList.Add({3.04334440892472, 2.93170442205242, 3.29259333216362})
    pointList.Add({2.83571388272942, 3.47374025854163, 3.48463520112399})
    pointList.Add({2.50888367106954, 3.07418111562898, 2.64570009782945})
    pointList.Add({3.15226279076008, 2.75025250495814, 3.00843798147578})
    pointList.Add({2.95821265593467, 3.11752142253449, 3.02171111394064})
    pointList.Add({2.66071004287717, 2.94412783824948, 3.19547025759234})
    pointList.Add({3.21605800684465, 3.2694710758628, 3.48450254875554})
    pointList.Add({3.34954229884519, 3.31347474485585, 3.15606355294825})
    pointList.Add({3.42331147061332, 3.03778835755942, 3.08440740773763})
    pointList.Add({3.45596302599724, 3.24599918759845, 2.59356922624118})
    pointList.Add({3.22593834176523, 3.27319241757686, 2.50651309915885})
    pointList.Add({2.848410415644, 2.76083476656012, 2.52695199319587})
    pointList.Add({3.31350316599623, 2.90990497151616, 3.13164772902983})
    pointList.Add({3.23849937268619, 2.81275726707495, 2.70824045540564})
    pointList.Add({3.27010402897502, 2.50554763932174, 2.89074370855214})
    pointList.Add({6.03171604366068, 6.2369863658183, 6.46052767137455})
    pointList.Add({6.21868609107726, 6.60324675344064, 6.0760255188223})
    pointList.Add({6.68347083745324, 6.38958336177638, 6.51876646431921})
    pointList.Add({6.02590336125965, 6.29314605198953, 6.87721088428824})
    pointList.Add({6.28273404197246, 6.49501950640024, 6.3082468027405})
    pointList.Add({6.08005800815136, 6.26345301557321, 6.28448164273499})
    pointList.Add({6.34407817456128, 6.72248530698692, 6.71923154146295})
    pointList.Add({6.22222319986778, 6.40555911096642, 6.52567583570522})
    pointList.Add({6.41064679354086, 6.1233007580428, 6.98013242023898})
    pointList.Add({6.32178331420294, 6.97241177046298, 6.29296629210209})
    pointList.Add({6.0501377402065, 6.06212921598852, 6.48671837639896})
    pointList.Add({6.25690273546385, 6.37864156635787, 6.50668821102947})
    pointList.Add({6.9068586336927, 6.81987015929395, 6.66927897353305})
    pointList.Add({6.80226723171158, 6.34029718742271, 6.53200446803696})
    pointList.Add({6.46162490340446, 6.65813834100971, 6.0618085860513})
    pointList.Add({6.54163382082062, 6.72005185247703, 6.11382541233568})
    pointList.Add({6.3269358376417, 6.84327085039352, 6.91845836975826})
    pointList.Add({6.07847962725181, 6.43149550206036, 6.6411765986094})
    pointList.Add({6.29041807273645, 6.25503712894561, 6.90024238715934})
    pointList.Add({6.46479653452691, 6.45717092332963, 6.06954748288729})

    Dim test = pointList.ToArray

    ' To create a tree from a set of points, we use
    Dim tree = KDTree.FromData(Of Integer)(pointList.ToArray)

    Dim query = New Double() {6, 6, 6}
    Dim radius As Double = 2.0

    ' Locate all nearby points within an Euclidean distance of 1.5
    ' (answer should be a single point located at position (5,4))
    '
    Dim result As KDTreeNodeCollection(Of KDTreeNode(Of Integer)) = tree.Nearest(query, radius)

Проблема в том, что я получаю определенное количество узлов в зависимости от того, какое значение радиуса я установил. Это похоже на то, как метод берет все, что я помещаю в параметры для радиуса, и конвертирую его в целое число и возвращает это количество точек.

Я ожидаю, что все точки в пределах определенного радиуса. Случай выше. Если я использую 6,6,6 в качестве точки поиска и радиус 2, я ожидаю получить около 20 точек назад, поскольку будет около 20 точек, которые составляют около 6,6,6. Вместо этого я получаю две ближайшие точки.

Существует два разных метода, документированных с одной и той же подписью в документации. Это смущает меня.

Документация для дерева Accord KD

KDTreeBase (Of TNode). Ближайший метод (Double (), Double)

и

KDTreeBase (из TNode). Ближайший метод (Double (), Double)

Что я делаю не так?

EDIT: Когда я использую пример из документации:

    Dim points =
{
    New Double() { 2, 3 },
    New Double() { 5, 4 },
    New Double() { 9, 6 },
    New Double() { 4, 7 },
    New Double() { 8, 1 },
    New Double() { 7, 2 }
}

' To create a tree from a set of points, we use
Dim tree = KDTree.FromData(Of Integer)(points)

' Now we can manually navigate the tree
Dim node = tree.Root.Left.Right

' Or traverse it automatically
For Each n As KDTreeNode(Of Integer) In tree
    Dim location = n.Position
    Console.WriteLine(location.Length)
Next

' Given a query point, we can also query for other
' points which are near this point within a radius
'
Dim query = New Double() {5, 3}

' Locate all nearby points within an Euclidean distance of 1.5
' (answer should be a single point located at position (5,4))
'
Dim result = tree.Nearest(query, radius:=1.5)

' We can also use alternate distance functions
tree.Distance = Function(a, b) Accord.Math.Distance.Manhattan(a, b)

' And also query for a fixed number of neighbor points
' (answer should be the points at (5,4), (7,2), (2,3))
'
Dim neighbors = tree.Nearest(query, neighbors:=3)

Я получаю сообщение об ошибке: Тусклый результат = дерево. Ближайший (запрос, радиус: = 1,5)

говоря:

«радиус» не является параметром «Ближайшая функция публичных перегрузок (позиция как Double (), соседи как целое число) как KDTreeNodeCollection (Of KDTreeNode (Of Integer))».

Это похоже на то, что VB.NET не видит ни один из методов с радиусом или расстоянием типа double в списке параметров.

...