Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm sorry if my question in not for here and because it's so stupid. I have a function, which draws a rectangle - it takes 4 parameters - width and lenght and 2 for positioning it. However, this is not so important. What I want to do, is to rotate it. Can you please tell e what to do with the coordinates of the rectangle to rotate it for example with 45 degrees?

share|cite|improve this question
what is the center of the rotation ? – lorenzo Nov 11 '12 at 22:54
The center of the figure – Faery Nov 11 '12 at 22:55
The center of the rectangle, you mean? – Rahul Nov 11 '12 at 23:42

After writing down the coordinates of the corners of your rectangle, you'll want to multiply the coordinates (technically, the vector) by the rotation matrix: $$\begin{pmatrix} cos \theta & -sin \theta\\ sin \theta & cos \theta \end{pmatrix}$$ $\theta$ is the angle you want to rotate the rectangle(counterclockwise).

So, if your coordinate is $(x,y)$, your rotated coordinate will be: $$(xcos\theta+ysin\theta, -xsin\theta + ycos\theta)$$

Note: this assumes you're rotating about the origin.

share|cite|improve this answer
Thanks very much! :) – Faery Nov 11 '12 at 23:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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