A rigid transformation of a square array is a mapping from square arrays of a certain size to square arrays of the same size, which rearranges the elements of the array such that the distance to each other element remains the same.
If you printed out the matrix on a sheet of paper these are the transforms you could do to it without tearing or folding the paper. Just rotating or flipping it.
For example on the array:
\$ \begin{bmatrix} 1 & 2 \\ 4 & 3 \end{bmatrix} \$
There are 8 ways to rigidly transform it:
\$ \begin{bmatrix} 1 & 2 \\ 4 & 3 \end{bmatrix} \begin{bmatrix} 2 & 3 \\ 1 & 4 \end{bmatrix} \begin{bmatrix} 3 & 4 \\ 2 & 1 \end{bmatrix} \begin{bmatrix} 4 & 1 \\ 3 & 2 \end{bmatrix} \begin{bmatrix} 3 & 2 \\ 4 & 1 \end{bmatrix} \begin{bmatrix} 4 & 3 \\ 1 & 2 \end{bmatrix} \begin{bmatrix} 1 & 4 \\ 2 & 3 \end{bmatrix} \begin{bmatrix} 2 & 1 \\ 3 & 4 \end{bmatrix} \$
The first \$4\$ are just rotations of the matrix and the second \$4\$ are rotations of it's mirror image.
The following is not a rigid transform:
\$ \begin{bmatrix} 2 & 1 \\ 4 & 3 \end{bmatrix} \$
Since the relative position of \$2\$ and \$3\$ has changed. \$2\$ used to be opposite \$4\$ and next to \$1\$ and \$3\$, but now it is opposite \$3\$ and next to \$1\$ and \$4\$.
For some starting arrays "different" transforms will give the same array. For example if the starting array is all zeros, any transform of it will always be identical to the starting array. Similarly if we have
\$ \begin{bmatrix} 1 & 0 \\ 1 & 0 \end{bmatrix} \$
The transforms which mirror it and rotate it a half turn, although they gave different results on the first example, give the same result in this example.
There are never more than \$8\$ unique transforms, the \$4\$ rotations and \$4\$ mirror rotations. Even when we scale the matrix up. So the number of unique results is always less than or equal to 8. In fact a little bit of math can show that it is always 1, 2, 4, or 8.
Task
Take a non-empty square array of non-negative integers as input and return the number of unique ways to continuously transform it.
This is code-golf so the goal is to minimize the size of your source code as measured in bytes.
Test cases
5
=> 1
0 0
0 0
=> 1
0 1
1 0
=> 2
0 1
0 0
=> 4
0 1
0 1
=> 4
2 1
1 3
=> 4
3 4
9 1
=> 8
1 2
1 0
=> 8
0 1 0
1 1 1
0 1 0
=> 1
0 2 0
0 0 0
0 0 0
=> 4
0 2 0
2 0 0
0 0 0
=> 4
0 2 0
6 0 0
0 0 0
=> 8