I am having problems getting this job, so it will be very helpful for us to help.
Short version: given the midpoint and size of the cube, I need to split it into 8 smaller ones (2x2x2) and, possibly, repeat for each of them. The resulting coordinates are the only thing needed.
I am writing an octree style code, and I am trying to allow it to accept inputs at different depths (depth refers to the distance between points, which 2^depth, for example, depth 0 has 1 unit of mesh, depth -1 has 0.5, depth 1 - 2). I need it so that it can get the coordinate at a higher depth and break it into cubes that correspond to the actual depth.
For example, if I have a point (0,0,0)at a depth of 1, and the scene is at a depth of 0, I need to break it into 8 parts and move each +-0.5units to place it in the old cube ( 2^(depth-1)).
If the scene is at a depth of -1, I need to break it into 8 parts, and then break it into 8 parts. I basically need it to give results 8^(difference in depth), it sounds pretty easy, but it completely made me go wrong.
octreeRange = ( 1, -1 )
octreeStructure = set()
for x in octreeRange:
for y in octreeRange:
for z in octreeRange:
octreeStructure.add( ( x, y, z ) )
def recursiveCoordinate( coordinate, coordinateInfo, minDepthLevel, octreeStructure ):
newDictionary = {}
if type( coordinateInfo ) != list:
coordinateInfo = [coordinateInfo,minDepthLevel]
coordinateDepth = coordinateInfo[1]
if coordinateDepth > minDepthLevel:
coordinateInfo[1] -= 1
moveAmount = pow( 2, coordinateDepth-1 )
for i in octreeStructure:
newCoordinate = [i[j]*moveAmount+coordinate[j] for j in xrange( 3 )]
newDictionary.update( recursiveCoordinate( newCoordinate, coordinateInfo, minDepthLevel, octreeStructure ) )
else:
newDictionary[tuple( coordinate )] = coordinateInfo
return newDictionary
minDepthLevel = 0
grid = {}
grid[(1.5,0,0)] = [1,2]
newGrid = {}
for coordinate in grid:
newGrid.update( recursiveCoordinate( coordinate, grid[coordinate], minDepthLevel, octreeStructure ) )
print len( newGrid.keys() )
For a visual idea, take this image. The midpoint is in the middle, defined at depth level 2, when the scene is at level 0. Solid black lines are the first iteration, and dashed lines will be the second and last iteration. I need the coordinates of all the midpoints of the dashed lines.

, , , 3 , , .
: , 2D-, , , . 64 , .
