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.
IndexProgramming Questions & HelpPrograms › Radians , Degrees
Page Index Toggle Pages: 1
Radians , Degrees (Read 472 times)
Radians , Degrees
Mar 27th, 2010, 5:51am
 
I want to create a loop, that takes an angle at 0 and adds X degrees each time it redraws, until it reachces 360 degrees.

It`s explained in the learning section of the site how to handle degrees and radians:

theta = angle*pi/180
angle = theta*180/pi

theta = radians(angle)
angle = degrees(theta)



but I still cant really see through it.


Code:
void rotate()
{
float cyrcleDegrees = degrees(TWO_PI);
float angle = 0;

for(int i=0;i<cyrcleDegrees;i++){

angle = angle + degrees(i*pi/18);
println("AngleDegrees: " + angle+ " at rotation: " + i);
}




Please help


Re: Radians , Degrees
Reply #1 - Mar 27th, 2010, 6:00am
 
i just edited the code from your "0...1 " post...


isnt this what you want ?



void setup() {
 size(600,400,P3D);
 noStroke();
 background(0);
}
float angle = 0;
void draw() {
 fill(0,2);
 rect(0,0,width,height);

 translate(width/2,height/2);
 angle = (angle%360)+1;
 
 fill(255,255,0);
 rotate(radians(angle));
 rect(100,0,10,10);
 
}

Re: Radians , Degrees
Reply #2 - Mar 27th, 2010, 6:02am
 
you could also use
x = cos( a );
y = sin( a );

to calc the exact position if you want to. but rotate might be enough.
Page Index Toggle Pages: 1