Re: 2D vector graphics Problem
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: 2D vector graphics Problem

From: Fredrik Lundh <fredrik@pythonware.com>
Date: Mon May 30 2005 - 12:43:24 CEST

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>
Received on Thu Sep 29 16:16:16 2005