8
$\begingroup$

I am trying to do some intersection tests and so the math gets weird if two certain points have the same $x$ coordinate and so infinite slope. The points can be anywhere in any quadrant.

I want to "rotate" all my points through $90^o$ which will preserve what I need while making the math easier.

For a point $(x, y)$ is it just changing it to $(y, x)$?

$\endgroup$
  • 2
    $\begingroup$ Depends really where you want to rotate from. Is it the origin? $\endgroup$ – Kbot Jun 18 '15 at 13:31
  • 1
    $\begingroup$ @Kbot Yes, rotating about the origin $\endgroup$ – KaliMa Jun 18 '15 at 13:32
  • 1
    $\begingroup$ If you want to rotate by 90 degrees, you would first exchange the x, and y's, then, since either one or the other will have to change sign, multiply one of them by -1, depending on whether you want to go clockwise or counterclockwise $\endgroup$ – Kbot Jun 18 '15 at 20:11
12
$\begingroup$

No: replace $(x, y)$ with $(-y, x)$. That will rotate 90 degrees counterclockwise about the origin.

What you proposed will flip everything around a 45-degree line that runs from southeast to northwest.

BTW: To rotate clockwise, replace $(x, y)$ with $(y, -x)$.

$\endgroup$
  • 1
    $\begingroup$ Note: This is correct for conventional Cartesian coordinates, where the Y-axis points UP. If your Y-axis points down (which is common in image processing software), then this would rotate CLOCKWISE. (A counter-clockwise rotation could be achieved via (y, -x)). $\endgroup$ – Stuart Berg Dec 20 '17 at 23:52
  • $\begingroup$ guyz could you tell us, how are you figuring out the formulas $\endgroup$ – Jumabek Alihanov Mar 27 '18 at 0:33
  • 1
    $\begingroup$ A unit-length arrow from the origin in direction $t$ (measure counterclockwise from the $x$-axis) has coordinates $(x, y) = (\cos t, \sin t)$. So rotating by 90 degrees CCW has coordinates $(\cos t + \frac{\pi}{2}, \sin t + \frac{\pi}{2} )$. Trig rules tell you that this is the same as $(-\sin t, \cos t) = (-y, x)$. So rotating $(x, y)$ by 90 degrees gets you $(-y, x)$. $\endgroup$ – John Hughes Mar 27 '18 at 4:08
0
$\begingroup$

If you represent the point $(x,y)$ in the plane as a complex number $x+iy$, then multiplying it by $i$ rotates it $90^\circ$ counterclockwise and multiplying it by $-i$ rotates it $90^\circ$ clockwise.

$\endgroup$
0
$\begingroup$

The new coordinates $(x_1,y_1)$ in terms of old:

$$ (x_1,y_1)= (-y,x) $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.