On 5/6/05, Joe Van Dyk <joevandyk / gmail.com> wrote:
> On 5/5/05, Hidetoshi NAGAI <nagai / ai.kyutech.ac.jp> wrote:
> > From: Joe Van Dyk <joevandyk / gmail.com>
> > Subject: Re: Ruby-tk question
> > Date: Fri, 6 May 2005 10:41:39 +0900
> > Message-ID: <c715e6405050518413e8952ea / mail.gmail.com>
> >
> > > On 5/5/05, Hidetoshi NAGAI <nagai / ai.kyutech.ac.jp> wrote:
> > > > From: Joe Van Dyk <joevandyk / gmail.com>
> > > > Subject: Ruby-tk question
> > > > Date: Fri, 6 May 2005 09:24:01 +0900
> > > > Message-ID: <c715e64050505172319751570 / mail.gmail.com>
> > > > > What's the easiest way to rotate a Tk Canvas Polygon?
> > > > Probably, you'll have to calculate coords by yourself.
> > > Hm, I have no idea how to do that.  Trig was so long ago.
> >
> > That is field of Mathematics. :-)
> > I think that is not so difficult.
> > --
> > Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp)
> >
> 
> It's horribly difficult for someone who hasn't done math in years.
> 
> 

Well according to a random math site:

def deg2rad(x)
       (x * Math::PI) / 180.0 
end

def rotate(x, y, deg)
       r = Math.sqrt(x**2 + y**2)
       theta = Math.atan(y/x)
       u = r * Math.cos(theta + deg2rad(deg))
       v = r * Math.sin(theta + deg2rad(deg))
       [u, v]
end

seems to work pretty well

rotate(1.0, 0.0, 90.0) #=> [6.12323399573677e-17, 1.0]

that is of course if you except 6.blah times 10 to the negative 17 is
close enough to zero for governement work.

This method is SUPPOSED to convert them into polar coordinates and
then rotate them by deg degrees. I don't prentend to know that its
correct
Math site formula was stolen from:
http://mathforum.org/library/drmath/view/63184.html