my matrix rotation logic