Thursday, September 10, 2009
/*
* moving with polar coordinate system
*
* For extra information:
* http://en.wikipedia.org/wiki/Polar_coordinate_system
*/
int H,K;
float w; // angular
float phi; // shift
float A,a; // Amplitude function
int N; // Total Steps
float phi_delta; // how fast to rotate the thing
float w_delta; // how many petals
void setup()
{
size(600,600);
smooth();
frameRate(25);
H = width/2;
K = height/2;
N = 600;
phi = 0.0f;
w = 0.0f;
}
void draw()
{
float x,y;
background(#C1B28C); // tanish brown
fill(#C62E66); // Redish Polar graphs
// Draw points
for( int i = 0; i < N; i++ )
{
// Polar Equation
a = 275*sin(w_delta*i+phi); // y = A sin(theta)
// convert polar to rect coordinate
x = a*cos(i) + H;
y = a*sin(i) + K;
// plot points
rect(x,y,5,5);
}
w_delta = ((float)mouseX)/width;
phi_delta = ((float)mouseY)/height;
// rotation is done with shifting
phi = phi + phi_delta;
w = w + w_delta;
}
* moving with polar coordinate system
*
* For extra information:
* http://en.wikipedia.org/wiki/Polar_coordinate_system
*/
int H,K;
float w; // angular
float phi; // shift
float A,a; // Amplitude function
int N; // Total Steps
float phi_delta; // how fast to rotate the thing
float w_delta; // how many petals
void setup()
{
size(600,600);
smooth();
frameRate(25);
H = width/2;
K = height/2;
N = 600;
phi = 0.0f;
w = 0.0f;
}
void draw()
{
float x,y;
background(#C1B28C); // tanish brown
fill(#C62E66); // Redish Polar graphs
// Draw points
for( int i = 0; i < N; i++ )
{
// Polar Equation
a = 275*sin(w_delta*i+phi); // y = A sin(theta)
// convert polar to rect coordinate
x = a*cos(i) + H;
y = a*sin(i) + K;
// plot points
rect(x,y,5,5);
}
w_delta = ((float)mouseX)/width;
phi_delta = ((float)mouseY)/height;
// rotation is done with shifting
phi = phi + phi_delta;
w = w + w_delta;
}
comments
loading...
Add a comment: