UtilityToolsLab

© 2026 UtilityToolsLab. All rights reserved.

Privacy Policy·Terms of Service·Sitemap
HomeCompetitive ProgrammingMatrix Rotation

Related Tools

Code FormatterMatrix GeneratorComplexity CalcBit VisualizerBitmask PlannerPrime FactorsMEX CalcInterval MergerPBDS GeneratorSegment TreeGraph VisualizerStress TesterModulo CalcBinary VisualizerConvex HullPath Finder

Matrix Rotation Simulator

Input a 2D matrix, choose 90°/180°/270° CW or CCW rotation. See the visual index shift and get the C++ implementation.

How to Use

  1. 1Open Matrix Rotation Simulator above. No signup or installation needed.
  2. 2Type or paste your input. Everything runs locally in your browser — nothing leaves your device.
  3. 3See results instantly. Hit Copy to grab the output.
  4. 4Star the tool to save it to Favorites for quick access next time.

Frequently Asked Questions

Is Matrix Rotation free?

Yes, completely free. No sign-up, no credit card, no usage limits.

Do you store my data?

Never. Everything runs 100% in your browser. Nothing is uploaded to any server.

Does it work on mobile?

Yes. All tools are fully responsive and work on phones, tablets, and desktops.

Original (3×3)

1
2
3
4
5
6
7
8
9

After 90° CW (3×3)

7
4
1
8
5
2
9
6
3

Index Mapping: original[r][c] → rotated[r'][c']

ValueOriginal [r][c]Rotated [r'][c']
1[0][0][0][2]
2[0][1][1][2]
3[0][2][2][2]
4[1][0][0][1]
5[1][1][1][1]
6[1][2][2][1]
7[2][0][0][0]
8[2][1][1][0]
9[2][2][2][0]

C++ Implementation

// Rotate 90° Clockwise
void rotateMatrix(vector<vector<int>>& mat, int rows, int cols) {
    // 90° CW: transpose then reverse each row
    // Step 1: transpose
    for (int i = 0; i < rows; i++)
        for (int j = i+1; j < cols; j++)
            swap(mat[i][j], mat[j][i]);
    // Step 2: reverse each row
    for (auto& row : mat) reverse(row.begin(), row.end());
}