More pythonic circle?

John Machin sjmachin at lexicon.net
Sun Apr 9 19:29:09 EDT 2006


[Michael Tobis]
Also, with this code, you are using radius for the dimensions of the
enclosing box, as well as the radius of the circle, so it's guaranteed
to not to actually produce a whole circle. Recall what python does with
negative indices!

[Pythor]
I'm not sure what you mean here.  It produces an eighth-circle, and
then plots each point in the 8 symmetrical positions on the circle.
Except for the (dx+1) point made above, what piece of the circle is
missing?
======
What Michael means is that for example a circle of radius 5 is 11
pixels wide and 11 pixels high. You are trying to cram it into a box of
5 x 5 pixels [or maybe 6x6 (I'm numpy-challenged)]. The result will
resemble a train smash. Have you considered *TESTING* your code? It's
not very difficult at all to draw the expected results for radii of
about 4 or 5 pixels on the back of an envelope ...

By the way, there are signs of a benchmark war breaking out. What are
typical sizes you would be using in practice for the radius and the
enclosing box?

Cheers,
John




More information about the Python-list mailing list