RE: [OT] rotating 90 degrees (was Logic)

Well, it all comes down to reassigning your axes then applying the offset
required to bring the picture back on the screen.

Clockwise 90 degrees:
New X=Y.
New Y=-X.

Thus, a pixel originally at (50,100) would end up at
(50*(new X),100*(new Y))
(50*(0,1), 100*(-1,0))
((0,50) + (-100,0))
(-100,50)

simpler: newpoint.x=-point.y; newpoint.y=point.x;

Then you need to bring that picture back. Because rotating around (0,0)
brought your picture out of view. Since you rotated from

----> <-----
| X Y |
| to |
V Y X V

The offset for (0,0) is (W,0) where W is the width of your picture.

Therefore, the point we calculated previously fall at
(-100,50) + (W,0) = (-100 + W, 50)

finally: newpoint.x=-point.y+W; newpoint.y=point.x;

I demonstrated rotating 90 clockwise, you can generalize with other
increments. Hope this helps! :S Of course, if you don’t have a square
picture, some points will generate coordinates out of screen space.

Mat

-----Original Message-----
From: Nitin Kapoor [mailto:xxxxx@hotmail.com]
Sent: Friday, March 21, 2003 3:42 AM
To: NT Developers Interest List
Subject: [ntdev] Logic

Hello Eceryone,

Please help me with some logic here,i am trying to write a rotate driver
which would rotate the desktop in 90 degrees increments.Well,i have being
working with the rotate algorithm of it and have come up with these ideas
but somewhat dont know which would be more easier and logical to
implement.To Explain it with diagrams

This is my destop before rotation

(x,y)-----------(x1,y1)
| |
| |
| |
| |
| |
| |
(x2,y2)---------(x3,y3)

if i rotate it 90 degrees it will become lke this:

(x1,y1)----------(x3,y3)
| |
| |
| |
| |
| |
| |
(x,y)---------(x2,y2)

Now i know that the upper-leftmost pixel of the Desktop is given by the
coordinates (0,0) i.e x,y in the first diagram and (x1,y1) in the second
diagram should be (0,0).

so coming to the question of rotation,should i:

a)using mathematics and use Sin theta and cosine theta and implement
rotation like i would have done with normal bitmaps.

or

b)Since i am writing a Video/Display Driver and have access to the memory
implement rotation by changing the contents of the memory.i.e:if i have to
rotate by 90 degrees ,i change the contents of (x,y) by (x1,y1) and (x1,y1)
by (x3,y3).

I have a feeling that it is possible with the second approach but dont know
if its even possible or not.

Please mail me with ur sugestions and ideas.

Thanks & regards,

Nitin Kapoor


You are currently subscribed to ntdev as: xxxxx@guillemot.com
To unsubscribe send a blank email to xxxxx@lists.osr.com