2D vector graphics Problem

Fredrik Lundh fredrik at pythonware.com
Mon May 30 06:43:24 EDT 2005


Scott David Daniels wrote:

> Your equation for y uses the new x, not the old x.  Be more free with
> names.  Here's one way to write it:
>
> class ...
>     def rotate(self, angle):
>         '''Rotate point angle radians around relPoint'''
>         x, y = self.coords
>         xRel, yRel = self.relPoint
>         sin, cos = math.sin(angle), math.cos(angle)
>         newx = x * cos - y * sin - xRel * cos + yRel * sin + xRel
>         newy = x * sin + y * cos - xRel * sin - yRel * cos + yRel
>         self.coords = newx, newy

and here's another one:

    http://online.effbot.org/2004_09_01_archive.htm#tkinter-complex

</F> 






More information about the Python-list mailing list