# How can I rotate a rectangle complete 360 degree

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?

• What software is doing the rotating?
– Paul
Sep 2, 2021 at 9:16
• C++ I used to rotate Sep 2, 2021 at 9:40
• For the angle you should be using atan2 Sep 2, 2021 at 10:12
• I suggest that you either post this on stack overflow with the associated code. Or here, but with the mathematical equations you used. There should be a mistake somewhere, but what you provide is not detailed enough to investigate. Sep 2, 2021 at 10:13
• This is probably a coding issue rather than a maths issue, your transformation is ok.
– Paul
Sep 2, 2021 at 10:42