Identifying inner cubes within a stack of cubes

storman

New member
Joined
Oct 24, 2021
Messages
4
Hey there, I'm developing a game and need help figuring out if there's a function to help me identify the inner cubes in a stack of cubes. I've attached illustrations of what I mean. Each cube is given a corresponding number starting at the bottom at x1z1y1 (just called 1). Each cube is counted up as shown in the diagram. I'm trying to identify what the center cube numbers are given the construction of the cube, and whether there's a function which will work for any proportion of cube stack. So in the examples below, for a 4x3x4 stack the center cube numbers are 18,19,30 and 31. For the other example a 4x4x5 stack the center cubes are 22,23,26,27,38,39,42,43,54,55,58,59.

Any clarification please don't hesitate to ask.
 

Attachments

  • 2021-10-24 15_53_05-Window.png
    2021-10-24 15_53_05-Window.png
    66.3 KB · Views: 4
  • 2021-10-24 15_53_15-Window.png
    2021-10-24 15_53_15-Window.png
    55.4 KB · Views: 4
I recommend that you solve the simpler 2d version of this problem first, and that should give you some insight into how to solve the 3d version. If you're still stuck then please post your attempt.
 
Hey! thanks for the reply I actually just managed to figure it out then. I basically made 6 different functions to lay out the cubes along a 2D plane, and then positioned the different functions and their 2D planes in 3D space relative to one another. Bit scuffed but hey at least it works.
 
Top