R/mirrormatrix.R

Defines functions mirrormatrix

Documented in mirrormatrix

# Mirror and rotate the boggle matrix
mirrormatrix=function(square=9){
stopifnot(sqrt(square)==round(sqrt(square)))
list(m0=matrix(1:square,byrow=TRUE,ncol=sqrt(square)), # zero
   m1=matrix(sqrt(square)*((((square-1):0))%/%sqrt(square))+(1+(0:(square-1))%%sqrt(square)),byrow=T,ncol=sqrt(square)), # flip horizontal
   m2=matrix(sqrt(square)*(((0:(square-1)))%/%sqrt(square))+(1+((square-1):0)%%sqrt(square)),byrow=T,ncol=sqrt(square)), # flip vertical
   m3=matrix(1:square,byrow=FALSE,ncol=sqrt(square)), # diagonal topleft
   m4=matrix(square:1,byrow=FALSE,ncol=sqrt(square)), # diagonal topright
   m5=matrix(sqrt(square)*(((0:(square-1)))%/%sqrt(square))+(1+((square-1):0)%%sqrt(square)),byrow=F,ncol=sqrt(square)), # rotation 1
   m6=matrix(square:1,byrow=TRUE,ncol=sqrt(square)), # rotation 2
   m7=matrix(sqrt(square)*((((square-1):0))%/%sqrt(square))+(1+(0:(square-1))%%sqrt(square)),byrow=F,ncol=sqrt(square)) # rotation 3
        )} 
vdweijer/games documentation built on Dec. 23, 2021, 3:02 p.m.