0
$\begingroup$

Suppose I had a an array of cubes with dimensions D * D * D.
For example, here is an image of an array of cubes where D = 3: a 3x3 array of cubes
I will refer to the array, being the collection of all cubes, and a cube being one single cube that is part of the array.

Each cube is of uniform size (S), and they are arranged in such a way where their sides touch each other, and there is no overlap. Just like the image. Each cube's center can be described as C.

Now imagine ranking these cubes in descending order of distance from point P to the cube's center C. The furthest cube from point P (max distance between P and C) will be given rank 1; the closest cube from point P will be given the largest number rank.

Given the following are true:
- Each cube is aware of its position in the array
- the rotation/orientation of the array is known
- each cube can be identified in any logical way. I would assume it's x, y and z positions in the array would make sense for identifying an individual cube

Given you following are known:
- P: the point we are measuring distance from
- M: the mid point of the cube array
- S: the size (side length) of each cube
- R: the Euler rotation (x, y, z) of the array.

I am looking for a function that will find me the cube ranked N by distance from point P to the cubes center C.

Constraint:
- I cannot assess the distance of all cubes to find which cube is ranked N. Although, it may be acceptable to assess the distance of one or two other cubes if it helps somehow.

I am a programmer, so I am actually looking for an algorithm or formula that will be performed on the GPU, in parallel, for each rank N at the same time.

Does such a function exist? Does this problem have a solution?

Thank you.


Edit:
For clarity, I am not intending to define areas in which the cubes fit. I am simply trying to rank the cubes based on their center position.

The most important thing is for each cube to given its own rank. I would accept solutions that have 2 cubes in slightly wrong order if they have, for example, very similar distances from P, but not a solution that can result in multiple cubes being given the same rank.

1 Answers 1

0

I looked at the similar problem for squares instead of cubes many years ago, and didn't find a formula then.

When I divided a square into regions that have the same sequence of 25 (say) nearest neighbours, I got many tiny, irregular polygons, perhaps triangles.

For regions that have the same set of 25 nearest neighbours, but maybe 23rd and 24th in a different order, I got dozens of small, irregular polygons.

So the calculation to identify the 25th nearest neighbour would, I guess, be time-consuming, with several linear inequalities followed by lookup.

EDIT

I wasn't clear what I was doing, so think of the four nearest points.
Sometimes they form a square, and sometimes they are one point and three neighbours, forming a tee.
There is an octagon in the square, touching all four sides, where the four nearest points are the corners of the square.
There are four kite shapes around each point where the four nearest points are that point and three of its neighbours.
The edge between the octagon and the kite is the line where the fourth and fifth points are the same distance.

  • 0
    Interesting. I'm going to add a bit more detail to my question. I have a feeling we may have slightly different problems as I'm not looking for polygons, but in fact the centre points of the cubes as simple positions in space. I also realised from your answer I can slightly relax the requirements perhaps.2017-02-08