More pythonic circle?
Pythor
pythor at gmail.com
Sun Apr 9 00:17:32 EDT 2006
John Machin wrote:
> OTTOMH, in a rush to go out: never mind Pythonic, following apply to
> any language:
> (1) accuracy: (a) sue me if I'm wrong, but I think you need range(dx+1)
> so that the dx pixel is filled in
Hmm. I think you're right. Thanks.
> (b) a few more digits after 0.71
> might be useful
Sine of 45 degrees is actually .707... I rounded up, since I was using
<=. Figured that would make it clear.
> (2) efficiency: seems that range(dy, dx+1) would save some wear & tear
> on the circuitry :-)
It took me a few minutes to figure out waht you meant here. This will
certainly help reduce the repeated coordinates. Thanks, again.
> (3) legibility: there's no prize for the script with the absolutely
> minimum number of space characters :-)
True. I assume your saying I should make cx,cy,dx, and dy better
names. I probably will. Up to now I was just playing around with
this, and not really expecting anyone else to read it.
> I think I've got an article on better Bresenham somewhere in the
> archives; will dig it out later.
I'd definitely appreciate it. In fact, I'm trying to find a decent
sphere version, and getting nowhere with google. I tried to figure it
out on my own, and ended up with 48 coordinates for each valid test.
I'm not sure if that's right.
Lee
More information about the Python-list
mailing list