# Board index » delphi » 2D rotation

## 2D rotation

I draw a square, then I rotate each of the 4 points with
x:= round(cos(0.5)*x- sin(0.5)*y);
y:= round(sin(0.5)*x + cos(0.5)*y);
(y, x are relative to the middle [0,0] of this rectangle )

After that I draw again, and the square is rotated
around its middle, but now the problem: it is distorted
(not right-angled and with a different height and width )

The rotation formula is OK, on paper is no distortion.
I tried all MapModes to no avail.
I don't get it, if the square is standing upright, then all
sides are equal, but not if it is rotated, I' don't see the
logic here.

Thank you v.m.
Tomas

## Re:2D rotation

On Fri, 15 Oct 1999 18:47:33 +0200, "T.W." <tor.wal...@t-online.de>
wrote:

##### Quote
>I draw a square, then I rotate each of the 4 points with
>x:= round(cos(0.5)*x- sin(0.5)*y);
>y:= round(sin(0.5)*x + cos(0.5)*y);
>(y, x are relative to the middle [0,0] of this rectangle )

>After that I draw again, and the square is rotated
>around its middle, but now the problem: it is distorted
>(not right-angled and with a different height and width )

Show us a small example of the actual code you're using.

-Steve

## Re:2D rotation

Steve Schafer

##### Quote
>T.W. wrote:
>>x:= round(cos(0.5)*x- sin(0.5)*y);
>>y:= round(sin(0.5)*x + cos(0.5)*y);
>Show us a small example of the actual code you're using.

Oops, my error, I should have written something like:
xnew:= round(cos(0.5)*x- sin(0.5)*y);
y:= round(sin(0.5)*x + cos(0.5)*y);
x := xnew;

Sorry