At 9:10 PM -0500 9/22/05, Andrew Krebs wrote:
Is there a way to find out at what x,y to draw the rotated image, so
that it is drawn as close to 0,0 as possible.
Ah, yes, that just requires a bit of trigonometry. If you know which
quadrant you're going to rotate it into, you can do this simply: for
example, just calculate the Y position of the top-left corner, and
the X position of the bottom-left corner, and shift your drawing by
that much.
If you don't know how much it'll be rotated, then you'll have to
calculate the position of all four corners, and find the minimum X
and Y of the set. Then shift by that much.
Let's see, I haven't had my coffee yet so I'm not sure this is the
simplest way to do it, but one way to find the rotated position of a
corner is to first convert it into polar coordinates (r =
sqrt(dx^2+dy^2), ang = ATan2(dx,dy)), then add the rotation amount to
the angle (ang), and convert back to cartesian coordinates (dx2 =
r*cos(ang), dy2 = r*sin(ang)).
Nothing that can't be solved with a little math! :)
HTH,
- Joe
--
Joe Strout REAL Software, Inc.
Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|