From 1e6cdd87c2265babb700e22d51c72a704fb11e0d Mon Sep 17 00:00:00 2001 From: "ludovic.castglia" Date: Mon, 27 Jan 2025 20:29:18 +0100 Subject: [PATCH] pour changer de pc --- 3nar.py | 5 +++- function.py | 8 +++-- spaceAround.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 spaceAround.py diff --git a/3nar.py b/3nar.py index 5693bb2..effb63f 100644 --- a/3nar.py +++ b/3nar.py @@ -29,6 +29,8 @@ class Nnnar: selected = [] subSpaceIdxList = getSpaceIdxAround(idx, nbAround, self) for subSpaceIdx in subSpaceIdxList: + print(subSpaceIdx) + print(self.space[subSpaceIdx]) selected += selectPointsInRange(self.space[subSpaceIdx],coord,nbAround*self.unit) nbAround += 1 found = [] @@ -75,4 +77,5 @@ class Point: n = Nnnar(2, 0, 3, 2) n.addPoint(np.array([1, 0.8]), 1) -print(n.space[0][0][0].coord) \ No newline at end of file + +print(n.getNNearest(np.array([1,0.8]),1)) \ No newline at end of file diff --git a/function.py b/function.py index e2ab420..5babd25 100644 --- a/function.py +++ b/function.py @@ -1,8 +1,12 @@ +from spaceAround import * def getSpaceIdxAround(center, nbAround, space): if (nbAround < len(space.calculatedSpaceAroundIdx)): - return space.calculatedSpaceAroundIdx[nbAround] - # TODO: implement l'algo pour trouver les indices subSapce à nbAround autour du centre + spaceAround = space.calculatedSpaceAroundIdx[nbAround] + else: + spaceAround = findCoordAround(center,nbAround) + space.calculatedSpaceAroundIdx.append(spaceAround) + return applySapceAroundToCase(center,spaceAround,space) def selectPointsInRange(points, coord, distance): found = [] diff --git a/spaceAround.py b/spaceAround.py new file mode 100644 index 0000000..93dd1f7 --- /dev/null +++ b/spaceAround.py @@ -0,0 +1,80 @@ +from sympy.utilities.iterables import multiset_permutations + +def findCoordAround(center, nbAround): + find = [] + for i in range(len(center)): + find = getNCoordDiff(center,find,i,nbAround) + return find + +def getNCoordDiff(center,find,nbDiffValue, nbAround): + coord = [] + if (-nbAround+nbAround >= nbDiffValue): + return find + for i in range(nbDiffValue): + coord.append(-nbAround+i) + while True: + modified = False + cursor = len(coord)-1 + while(not modified): + if (cursor<0): + return find + if (coord[cursor]+len(coord)-1-cursor