How can I rotate a rectangle complete 360 degree

148 Views Asked by At

I implemented the logic to rotate rectangle $90$ degree but the logic is not working for complete $360$. It rotates until $90$ then goes in reverse direction until $180$ then again come back on $225$ then again goes in reverse direction for $360$.

Means its going and coming back only in one quadrant.

The method I used is

  1. Found the center of rectangle
  2. Changed centre of position to orgin
  3. Did rotation
  4. Took back to original position

Logic used is $(x\cos\theta−y\sin\theta ,x\sin\theta+y\cos\theta)$.

Do I need another logic for complete $360$ degree rotation?