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 › Using rotate() - more narrow rotation
Page Index Toggle Pages: 1
Using rotate() - more narrow rotation? (Read 501 times)
Using rotate() - more narrow rotation?
Apr 6th, 2010, 5:32pm
 
Hello all. I'm currently experimenting with the rotate() and translate() functions, and I'm have trouble. Here is my code:
Code:

Ladybug ladybug;

void setup() {
size(800,600);
smooth();
ladybug = new Ladybug(50);
}

void draw() {
background(255);

ladybug.display();
ladybug.move();
}


Class:

Code:

class Ladybug {
float diam;
float theta=0;

Ladybug(float tempDiam) {
diam = tempDiam;
}

void display() {
pushMatrix();
rotate(theta);
translate(400,300);

fill(255,0,0);
ellipse(0,0,diam,diam);
popMatrix();
}

void move() {
theta+=.01;
}
}


As you can see, my rotation is very wide and even goes off the screen. How do I go about having a more narrow rotation?

Thanks  Smiley
Re: Using rotate() - more narrow rotation?
Reply #1 - Apr 6th, 2010, 7:25pm
 
Normally you would translate to the centre of rotation and then rotate....not the other way around...
Page Index Toggle Pages: 1