Check out example codes for "tetris rotate shape". It will help you in understanding the concepts better.

Code Example 1

# General formula for rotating around origin is xNew = x * cos(a) - y * sin(a) yNew = x * sin(a) + y * cos(a)  # For 90 degrees it becomes xNew = -y yNew = x

Learn ReactJs, React Native from akashmittal.com