• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Soma cube type puzzle solving (array rotation)

## Recommended Posts

OrangyTang    1298
I''m trying to write a little problem to solve a Soma cube varient. Each piece is represented by a 6x6x6 array of booleans, and will be a brute-force method of trying every combination all the pieces together which fit into the cubes bounds. Obviously each piece can be rotated around the x, y and z axies (at multiples of 90 deg.) and any combination of. This is where i''m stuck - how to ''rotate'' a 3d (or even 2d) array by a specified amount around an axis. After scrawling down variations and figuring out small examples, there doesn''t seem to be an obvious pattern. The only thing that springs to mind is to construct a matrix for the transformation (eg. 90 around x), then multiply the original indices (eg. [0][0], [2][4] etc.) by the matrix, then use the result as the destination indices. This seems like the long way around though, is there a more suitable and easier way? Thanks