Reflect and Rotate a Polyomino

POLYOMINO_TRANSFORM, a C library which transforms the matrix representing a polyomino by reflection and rotation.

The polyomino is described by an MxN matrix containing only 0 and 1 values.

A reflection is implemented by reversing the order of entries in each row.

A rotation of 90 degrees rotates the matrix counterclockwise. The values of M and N are also interchanged.

The transformation to be carried out will involve 0 or 1 reflections, followed by 0, 1, 2 or 3 rotations of 90 degrees.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


POLYOMINO_TRANSFORM is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

PENTOMINOES, a C library which provides some utilities for manipulating pentominoes.

POLYOMINO_CONDENSE, a C library which cleans up a matrix that represents a polyomino by setting all nonzero entries to 1, and removing initial and final rows and columns of zeros.

POLYOMINO_EMBED, a C library which is given matrices defining a region R and a polyomino P, and determines the number of possible embeddings of the polyomino into the region, and the translations necessary to achieve them.

POLYOMINO_ENUMERATE, a C library which enumerates chiral, fixed and free polyominoes up to a moderate order.

POLYOMINO_INDEX, a C library which is given a matrix defining a polyomino P, and determines a correspondingly shaped matrix which contains an index for each nonzero entry in P.

POLYOMINO_LP_WRITE, a C program which writes an LP file describing a (binary) integer programming problem related to the tiling of a region R by copies of polyomino shapes, with possible reflections and rotations.


  1. Solomon Golomb,
    Polyominoes: Puzzles, Patterns, Problems, and Packings,
    Princeton University Press, 1996,
    ISBN: 9780691024448

Source Code:

Examples and Tests:

List of Routines:

Last revised on 16 April 2018.