1
$\begingroup$

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?

$\endgroup$
7
  • $\begingroup$ What software is doing the rotating? $\endgroup$
    – Paul
    Sep 2, 2021 at 9:16
  • $\begingroup$ C++ I used to rotate $\endgroup$
    – Sijith
    Sep 2, 2021 at 9:40
  • 1
    $\begingroup$ For the angle you should be using atan2 $\endgroup$ Sep 2, 2021 at 10:12
  • $\begingroup$ 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. $\endgroup$ Sep 2, 2021 at 10:13
  • 2
    $\begingroup$ This is probably a coding issue rather than a maths issue, your transformation is ok. $\endgroup$
    – Paul
    Sep 2, 2021 at 10:42

0

You must log in to answer this question.

Browse other questions tagged .