diff --git a/fixedsizematrix.h b/fixedsizematrix.h index 1f3749a..b38a52e 100644 --- a/fixedsizematrix.h +++ b/fixedsizematrix.h @@ -3,6 +3,7 @@ #include #include +#include template class FixedSizeMatrix @@ -108,19 +109,33 @@ void FixedSizeMatrix::rotateRight() template void FixedSizeMatrix::rotate180() { - //TODO + //for(unsigned int y = 0; y < height / 2; y++) + // for(unsigned int x = 0; x < width; x++) + // std::swap(m_data[height-y-1][width-x-1], m_data[y][x]); + + mirrorHorizontally(); + mirrorVertically(); } template void FixedSizeMatrix::mirrorHorizontally() { - //TODO + //for(unsigned int y = 0; y < height / 2; y++) + // for(unsigned int x = 0; x < width; x++) + // std::swap(m_data[height-y-1][x], m_data[y][x]); + + std::reverse(std::begin(m_data), std::end(m_data)); } template void FixedSizeMatrix::mirrorVertically() { - //TODO + //for(unsigned int y = 0; y < height; y++) + // for(unsigned int x = 0; x < width / 2; x++) + // std::swap(m_data[y][width-x-1], m_data[y][x]); + + for(unsigned int y = 0; y < height; y++) + std::reverse(std::begin(m_data[y]), std::end(m_data[y])); } template