We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
newbie problem (Read 429 times)
newbie problem
May 14th, 2006, 8:20pm
 
Hi everyone!  I'm a newcomer to Processing and programing in general. I am trying to write a simple code that offsets a circle from the center and have the circle rotate around it.  I have the math portion right however i cannot seem to figure out how to animate the circle moving. Heres what i have so far..

void setup () {
 size (200,200) ;
 stroke (255) ;
 noFill () ;
 framerate (30) ;
}

void draw () {
 background (0);
 float rOne=20; // ellipse size
 float rTwo; // distance from center
 float theta;
 
 rTwo = rOne/(sqrt(3)/2);
 
 for (int i=0; i<360; i++) {
   theta = radians(i);
   ellipse (width/2+(cos(theta)*rTwo), height/2+(sin(theta)*rTwo),rOne,rOne);
 }
}

I'm still learning programing logistics so anyone who may ellucidate on my situation would be greatly appreciated! Feel free to ellaborate.  Thanks in advanced!
Re: newbie problem
Reply #1 - May 14th, 2006, 8:29pm
 
this will get it moving. You were drawing it 360 times per frame:

Code:


theta = radians(rot);
ellipse (width/2+(cos(theta)*rTwo), height/2+(sin(theta)*rTwo),rOne,rOne);

rot = rot+1%360;
}

float rot;

Re: newbie problem
Reply #2 - May 14th, 2006, 9:28pm
 
That makes sense, thanks a million!
Page Index Toggle Pages: 1