2
I would like to know how to return the numbers of a vector (matrix) within a specific R (radius) using Python.
Follow on this image:
Following the vector used:
mapa = [
[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
[1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6],
[2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6],
[3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6],
[4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 0.6],
[5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6],
[6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6]
]
Using row 3 node and column 3:
We have the respective exits
In R = 0:
[3.3]
In R = 1:
[2.2, 2.3, 3.2, 3.4, 4.2, 4.3]
In R = 2:
[1.2, 1.3, 1.4, 2.1, 2.2, 2.3, 2.4, 3.1, 3.2, 3.4, 3.5, 4.1, 4.2, 4.3, 4.4, 5.2, 5.3, 5.4]
If we still used an R = 3 we would have the outputs:
[0.1, 0.2, 0.3, 0.4, 1.1, 1.2, 1.3, 1.4, 1.5, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 3.0, 3.1, 3.2, 3.4, 3.5, 3.6, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 5.1, 5.2, 5.3, 5.4, 5.5, 6.1, 6.2, 6.3, 6.4]
I had made a weird code for learning returning in rectangular shape to help (https://github.com/MuriloChaves/Kohonen_Fausett/blob/master/vizinhanca/codigos/vizinhos_bidimensional_retangular.py)
A hexagonal matrix is identical to a "square" matrix, what changes is the calculation of the distance of the coordinates> When processing the distances you have to treat the diagonals of the right (or only of the left) in the same way as the vertical, or subtract/sum an offset of one of the axes when calculating the distances to each even (or odd, line depends on how organized). Do not forget that the Y (in the case of your chart) is not 1, you have to calculate the diagonal distance, and add with the horizontal offset (when it exists) * horizontal factor.
– Bacco
PS: In your case you can simplify using only offset, if only to determine concentric hexagons (without calculating real distance)
– Bacco
Does the order of the rotation (and the beginning) matter? Or can I pick up from any angle in any direction?
– Jefferson Quesado