mikepound / opencubes

A community improved version of the polycubes project!
MIT License
44 stars 23 forks source link

Idea: New way to encode shapes? #36

Open CallMeHein opened 12 months ago

CallMeHein commented 12 months ago

Encoding shape by "flattening" all three dimensions

The goal is to encode shapes by having a sort of "map" that tells you how many blocks are at a certain coordinate in a certain dimension.

An example will hopefully make it clearer:

Imagine the well-known T-Piece (4 Cubes) in a specific orientation, and the "Views" from each dimension:

Base
base

Top view
top

Side view
side

Front view
front

Note the numbers i have added to the images, these denote how many cubes are behind the one face that is visible when viewing from the indicated side.

These are the essence of my proposal, so the T-Piece could be represented by the following Matrices

[1 2 1]


[0 1 0] [1 1 1]


[1] [3]

As far as I can tell, these three arrays will describe any orientation of the T-Piece when viewed from the correct side and you won't have to check all possible 24 rotations to compare two polycubes.


Now for my questions:

Is this feasible to implement? Will this even be more efficient than what is done right now?

Please ask any questions you might have, I'm willing to concede if turns out to be a bad idea

Representations for n=1 to n=4

n=1

Just a 1x1x1 cube
[1]
[1]
[1]

n=2

1x1x2
[1 1]
[1 1]
[2]

n=3

Corner Long
[1 1] [0 1] [1 1 1]
[2 1] [1 1 1]
[1 2] [3]

n=4

Square L Long Z T Corner/Pyramid "Twisted Z" (the one that can be reflected)
[1 1]
[1 1]
[1 1 1]
[0 0 1]
[1 1 1 1] [1 1 0]
[0 1 1]
[0 1 0]
[1 1 1]
[1 2]
[0 1]
[2 1]
[0 1]
[2 2] [3 1] [1 1 1 1] [2 2] [3 1] [1 0]
[2 1]
[1 0]
[2 1]
[2 2] [1 1 2] [4] [1 2 1] [1 2 1] [0 1]
[1 2]
[1 0]
[1 2]

This should prove that each unique shape has three arrays which make a unique set to describe that shape, at least for n <= 4, hopefully for other n as well.

CallMeHein commented 11 months ago

Update: I have tried an implementation, but it breaks for n >= 6. Maybe someone else can work with this