topical media & game development
graphic-processing-learning-13-example-13-5-example-13-5.pde / pde
// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
// Example 13-5: Polar to Cartesian
// Polar coordinates (r, theta) are converted to Cartesian (x,y)
// for use in the ellipse() function.
float r = 75;
float theta = 0;
void setup() {
size(200,200);
background(255);
smooth();
}
void draw() {
// Polar to Cartesian conversion
float x = r * cos(theta);
float y = r * sin(theta);
// Draw an ellipse at x,y
noStroke();
fill(0);
ellipse(x + width/2, y + height/2, 16, 16); // Adjust for center of window
// Increment the angle
theta += 0.01;
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.