use A and D to rotate the box use the arrow keys to move the center of rotation code by me https://en.wikipedia.org/wiki/Rotation_matrix feel free to remix and experiment