# How to “rotate” points through 90 degree?

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)$?

• Depends really where you want to rotate from. Is it the origin? – Kbot Jun 18 '15 at 13:31
• @Kbot Yes, rotating about the origin – KaliMa Jun 18 '15 at 13:32
• 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 – Kbot Jun 18 '15 at 20:11

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)$.

• 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)). – Stuart Berg Dec 20 '17 at 23:52
• guyz could you tell us, how are you figuring out the formulas – Jumabek Alihanov Mar 27 '18 at 0:33
• 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)$. – John Hughes Mar 27 '18 at 4:08

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.

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

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