# polar coordinates?

Brian Christiansen brian_christians at hotmail.com
Sun Dec 9 11:30:13 EST 2018

```I have been messing with a program that is inspried by a video on
youtube that is about the vizualization of pi.  I might make a post
about that program someday, but I want to talk about something else.
One of the ways of visualizing it is to put dots corresponding to each
digits in a spiral pattern, in a color corresponding to what the digit
is. I think this would be easiest, at least in the initial calculation
of the point would be to use polar coordinates.

For example, if I were to use a very simple archimedian spiral, r = 0 +
(1 x theta), the "first 4" points, if theta increases by 1 degree
(4pi/360, 4pi/360) (6pi/360,6pi/360).

The problem is that python (more specifically tkinter or graphics.py
file that I downloaded) can't use polar coordinates directly to plot
points (or at least I don't think they can). The polar coordinates have
to be converted to cartesian coordinates, then converted to the
coordinate system that a computer uses to actually plot points on the
screen.

For example, the first point is just the origin, and its cartesian
coordinates are just (0,0), but if I use the statement point(0,0) to
plot the point, the computer will draw it at the upper left corner of
the screen, not at the center where I want it to be, so I need to add
however many pixels make up a "unit," to put it in the center of the
screen.  For instance if my screen that I was drawing on is 700 by 700,
I would have to add 350 to each coordinate value to get the point
(350,350), then plotting on to that point would place the point where I
want it, the center of the screen I have set up.

For the 2nd point, (2pi/360 "units", 2pi/360 radians) or (2pi/360
"units", 1 degree), that converts to the cartesian coordinate ~(.0003
"units",.0175 "units"), provided I did not get sin and cos mixed up, but
then for the computer to actually plot it, the computer has to calculate
how many actual pixels the x and y coordinates are offset from the
origin, then add these values to the location on the computer where the
origin is.  Since on the screen that was set up is 700 x 700 pixels
(approximately the largest square screen I can put use on my computer),
a "unit" is 350 pixels).

The X and Y offsets, recalcuated as pixels, is ~(350 x .0003,350 x
.0175) or ~(.105,6.125).  Then these offsets added (or subtracted in the
case of the y-coordinate since on a computer screen the y coordinates
are upside down) to the actual location of the origin, (350,350), and
rounded to the nearest integer, gives (350,344), which is the "screen
coordinates" of the point that is actually plotted.

Basically what would happen is that a polar coordinate within a unit
circle would be calculated, then the corresponding cartesian coordinate
would be calculated from that, then the actual screen coordinates would
be calculated based on where the center of the screen you set up is.

In setting up a screen, you might specify that the screen is 700 pixels
by 700 pixels and a unit is 350 pixels.  By that mapping, any point
outside of the unit circle (for the most part) will be off the screen.
If a unit is defined as 175 pixels, that circle is increased to a radius
of 2, if a unit is defined as 100 pixels, that radius is increased to
3.5, if a unit is defined to be 50 pixels that radius is increased to 7.
I think defining a unit as even fewer pixels than that would lose too
much resolution to be practical.

In sum, what all that would be is a method to map polar coordinates to
actual screen coordinates.

I guess my question is if python can do this natively or if there is a
package somewhere (polar.py?) that can do this. I know there are some
functions in cmath? that can help with parts of this, but I don't think
that python can do all of these things natively.  If there is a package
(or include file) that can do all of these things, I have not been able
to find it.

--
My Yonkoma: https://www.flickr.com/photos/brian0908/albums/72157680223526176

The E-mail associated with the account is a "spamcatcher" account that I
got to every couple of months to empty out, and anything sent to it will
not be seen for probably several months, if it is seen at all.
Brian Christiansen
```