Monday, April 21, 2008

Polar Coordinates

The polar coordinate system is another way of keeping track of points on the plane. Instead of using Descartes' x and y coordinates to determine the position of a point we use r and q. The polar coordinate system is based on a line drawn from the origin of coordinates to the point. The length of this line is r. The angle between the line and the x-axis is q.
The mathematical relationship between cartesian and polar coordinates goes as follows.
x = r cos(q)
y = r sin(q)
The objects cartopol and poltocar convert between cartesian and polar coordinates. The angle is measured in radians. The code is in the comments section.
Lots of very exciting mathematics surrounds this relationship between polar and cartesian coordiantes by way of exponentials and complex numbers. One such jewel is Euler's formula.

1 comment:

Tony said...

max v2;
#N vpatcher 20 74 277 417;
#P window setfont "Sans Serif" 9.;
#P hidden message 98 53 23 196617 0 0;
#P hidden message 20 54 35 196617 70 55;
#P user lcd 51 74 140 110 0 1 0 0 0;
#N vpatcher 329 533 1260 917;
#P button 407 262 15 0;
#P window setfont "Sans Serif" 9.;
#P message 407 283 354 196617 linesegment 70 0 70 110 246 \, linesegment 0 55 140 55 246 \, pensize 10 10;
#P message 146 308 60 196617 pensize 1 1;
#P button 146 200 15 0;
#P message 208 308 60 196617 pensize 2 2;
#P button 208 200 15 0;
#P newex 475 308 84 196617 prepend paintarc;
#P message 475 262 105 196617 \$1 \$2 \$3 \$4 \$5 \$6 7;
#P message 234 200 172 196617 \$1 \$2 70 \$2 248 \, \$1 \$2 \$1 55 248;
#P button 317 262 15 0;
#P message 317 308 60 196617 pensize 1 1;
#P newex 467 205 35 196617 - 180;
#P newex 467 185 40 196617 * 180.;
#P newex 467 165 63 196617 / 3.141594;
#P newex 467 145 63 196617 + 3.141594;
#P newex 382 225 115 196617 pack 0 0 0 0 90 360 28;
#P newex 382 308 89 196617 prepend framearc;
#P newex 321 99 29 196617 - 55;
#P newex 286 99 29 196617 - 70;
#P button 586 65 15 0;
#P message 586 308 32 196617 clear;
#P newex 286 121 45 196617 cartopol;
#P newex 391 154 30 196617 + 55;
#P newex 356 154 30 196617 + 70;
#P newex 321 154 32 196617 !- 55;
#P newex 286 154 32 196617 !- 70;
#P newex 286 176 153 196617 pack 0 0 0 0 255;
#P newex 286 225 93 196617 prepend frameoval;
#P newex 180 154 98 196617 pack 0 0 70 55 212;
#P newex 180 225 100 196617 prepend linesegment;
#P newex 138 154 27 196617 + 3;
#P newex 109 154 27 196617 + 3;
#P newex 80 154 27 196617 - 3;
#P newex 51 154 27 196617 - 3;
#P newex 51 176 127 196617 pack 0 0 0 0 255;
#P newex 51 225 88 196617 prepend paintoval;
#P newex 51 65 39 196617 unpack;
#P outlet 51 336 15 0;
#P inlet 51 31 15 0;
#P connect 0 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 1 0;
#P connect 9 0 1 0;
#P connect 18 0 1 0;
#P connect 11 0 1 0;
#P connect 22 0 1 0;
#P connect 28 0 1 0;
#P connect 32 0 1 0;
#P connect 36 0 1 0;
#P connect 34 0 1 0;
#P connect 37 0 1 0;
#P connect 2 1 6 0;
#P connect 6 0 4 1;
#P connect 2 0 7 0;
#P connect 7 0 4 2;
#P connect 2 1 8 0;
#P connect 8 0 4 3;
#P connect 10 0 35 0;
#P connect 35 0 36 0;
#P connect 2 0 10 0;
#P connect 10 0 9 0;
#P connect 30 0 9 0;
#P connect 2 1 10 1;
#P connect 10 0 33 0;
#P connect 33 0 34 0;
#P connect 10 0 30 0;
#P connect 2 0 20 0;
#P connect 20 0 17 0;
#P connect 17 0 13 0;
#P connect 13 0 12 0;
#P connect 12 0 11 0;
#P connect 23 0 29 0;
#P connect 29 0 28 0;
#P connect 2 1 21 0;
#P connect 21 0 17 1;
#P connect 17 0 14 0;
#P connect 14 0 12 1;
#P connect 17 0 15 0;
#P connect 15 0 12 2;
#P connect 13 0 23 0;
#P connect 23 0 22 0;
#P connect 17 0 16 0;
#P connect 16 0 12 3;
#P connect 14 0 23 1;
#P connect 23 0 38 0;
#P connect 38 0 37 0;
#P connect 15 0 23 2;
#P connect 16 0 23 3;
#P connect 17 1 24 0;
#P connect 24 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 27 0;
#P connect 27 0 23 5;
#P connect 23 0 31 0;
#P connect 31 0 32 0;
#P connect 0 0 19 0;
#P connect 19 0 18 0;
#P pop;
#P newobj 20 123 30 196617 p lcd;
#P flonum 90 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 50 281 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 90 240 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 50 240 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 10 59 410 359;
#P window setfont "Sans Serif" 9.;
#P newex 141 131 30 196617 * -1;
#P newex 141 109 29 196617 - 55;
#P newex 109 109 29 196617 - 70;
#P newex 109 155 42 196617 pack;
#P newex 109 84 42 196617 unpack;
#P outlet 109 183 15 0;
#P inlet 109 58 15 0;
#P connect 0 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 3 0;
#P connect 3 0 1 0;
#P connect 2 1 5 0;
#P connect 5 0 6 0;
#P connect 6 0 3 1;
#P pop;
#P newobj 51 189 44 196617 p offset;
#P window setfont "Sans Serif" 14.;
#P comment 126 277 87 196622 x \, y;
#P window setfont Symbol 14.;
#P comment 127 241 87 1507342 r \, q;
#P window setfont "Sans Serif" 9.;
#P newex 50 260 50 196617 poltocar;
#B color 5;
#P newex 50 217 50 196617 cartopol;
#B color 5;
#P hidden newex 20 30 45 196617 loadbang;
#P hidden message 56 53 39 196617 local 0;
#P hidden connect 1 0 13 0;
#P connect 12 0 11 0;
#P hidden connect 13 0 11 0;
#P connect 6 0 2 0;
#P hidden connect 14 0 2 0;
#P connect 2 0 7 0;
#P connect 7 0 3 0;
#P connect 3 0 9 0;
#P connect 11 0 12 0;
#P hidden connect 0 0 12 0;
#P connect 12 0 6 0;
#P hidden connect 1 0 0 0;
#P connect 2 1 8 0;
#P connect 8 0 3 1;
#P connect 3 1 10 0;
#P hidden connect 1 0 14 0;
#P pop;