Jump to content

Identifying a cube configuration

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
ThemePark

ThemePark

    Programmer

  • Members
  • PipPipPipPip
  • 124 posts
Suppose I have 27 cubelets. Each cubelet has an unique ID, uniquely identifying it to my main program. Each cubelet also has 6 magnets, one for each side. Each magnet in a cubelet also has a unique ID, although these IDs are the same for each cubelet. So the cubelets could be IDed with 0 to 26, and the magnets in a cubelet with 0 to 5.

Now I put the 27 cubelets together into a 3x3x3 cube. How, if at all, can I determine which cubelet has been placed where in the 3x3x3 cube? Obviously I can determine whether a cubelet is an corner, edge, center or middle cubelet, depending on how many magnets are turned on/attracted. But how do I determine whether 2 specific cubelets are next to each other, and which edge cubelet a corner cubelet is next to?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Without knowing more about the data, it's impossible to say. What relationships are known to exist?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
ThemePark

ThemePark

    Programmer

  • Members
  • PipPipPipPip
  • 124 posts
I don't really think there are any more relationships, not that I can think of.

Think of it as a Rubiks Cube, where all 27 cubelets are exactly the same on the outside, with the same colour on each of the 6 faces. The only thing that seperates each cubelet is its internal ID. So any cubelet can be positioned anywhere in the Rubiks Cube.

But whenever the Rubiks Cube has been assembled, the cubelets are locked into place. And since the cubelet keeps track of how many other cubelets it's connected with, you can for instance easily identify that the cubelet with ID 5 is a corner cubelet.

The thing is, it doesn't seem like I can figure out which cubelets each cubelet is connected to, other than the type of them. But I've seen this be done with a product called TileToy. So my question is also, what kind of information do I also need to be able to deduce the placement of each cube? And here I mean as little information as possible.

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
If each cube knows its neighbors, you can determine the overall arrangement (ignoring rotations and reflections). If you know which magnets are connected, then you can determine the overall arrangement (ignoring rotations).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
ThemePark

ThemePark

    Programmer

  • Members
  • PipPipPipPip
  • 124 posts
But can I deduce the neighbours of any cube, having only the IDs of each cube and the ID of each magnet and whether it's connected or not, available? Or do I need more information than that to determine it?

#6
ZekeDragon

ZekeDragon

    Writes binary right handed and hex left handed

  • Moderators
  • 2,103 posts
I think the best way would be to specify in which direction, and keep it static, each "magnet" on the faces of the cubelets is facing. Namely, you should have magnet ID 0 facing the, say, positive Z direction, 1 facing the positive Y, 2 facing positive X, 3 facing negative X, 4 facing negative Y, and 5 facing negative Z. This would make it possible for each cubelet to directly determine where it is in the cube, since each combination of activated magnets would be unique. Thus, each cubelet would need a bool array, like so:
class Cubelet
{
    bool magnets[6];
And each ID would identify which direction the activated magnets are in. This way, you don't need to directly determine which magnet is attached to which cubelet, but you can also ascertain the location of each cube. I suggest you also include an enum for each direction with that magnets array, to make it easier. You also can eliminate the variable you were using to track how many magnets were activated.

However, if you intend on scaling this cube to a higher number of cubelets, say 5 x 5 x 5, this would be entirely ineffective. In that case, you should instead keep coordinate values within the cubelets, an X, Y, and Z value, that would be the most scalable, and the algorithms to check if any cube is in the same location as any other cube would be relatively straightforward.
Wow I changed my sig!