optionally rotate matrix