Function Repository Resource:

ArrayRotations

Source Notebook

Get the rotations and reflections of an array

Contributed by: Ed Pegg Jr

ResourceFunction["ArrayRotations"][array]

returns the eight rotations and reflections of the given 2D array.

ResourceFunction["ArrayRotations"][array,False]

returns the four rotations only.

Examples

Basic Examples (2) 

The eight rotations and reflections of an array:

In[1]:=
basic = ResourceFunction[
  "ArrayRotations"][{{1, 1, 0}, {0, 0, 0}, {0, 0, 0}}]
Out[1]=

Images of the returned arrays:

In[2]:=
ArrayPlot[#, PixelConstrained -> 20] & /@ basic
Out[2]=

Show only the rotations:

In[3]:=
rots = ResourceFunction[
  "ArrayRotations"][{{1, 1, 0}, {0, 0, 0}, {0, 0, 0}}, False]
Out[3]=
In[4]:=
ArrayPlot[#, PixelConstrained -> 20] & /@ rots
Out[4]=

Scope (3) 

Six different arrays:

In[5]:=
sixarrays = Permutations[{{1, 1, 0}, {0, 1, 1}, {0, 1, 0}}];
ArrayPlot[#, PixelConstrained -> 20] & /@ sixarrays
Out[5]=

A canonical form of each array under symmetry:

In[6]:=
canonicalsix = First[Sort[ResourceFunction["ArrayRotations"][#]]] & /@ sixarrays;
ArrayPlot[#, PixelConstrained -> 20] & /@ canonicalsix
Out[6]=

A canonical form of each array using rotations only:

In[7]:=
canonicalsixrot = First[Sort[ResourceFunction["ArrayRotations"][#, False]]] & /@ sixarrays;
ArrayPlot[#, PixelConstrained -> 20] & /@ canonicalsixrot
Out[7]=

Version History

  • 1.1.0 – 21 September 2021

License Information