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
rotate ? (Read 593 times)
rotate ?
May 20th, 2009, 11:33am
 
well this is probably a high requested topic but i dodn't understand anything of other topics.

so, I want to rotate some shapes i've imported, but when i do the rotate(); comand it rotates to a point in the upper right corner of the canvas size... is there a way to move that point to the center of the canvas, or rotate the object within its own center ( center of the object)?

sorry to bother with these basic questions but i've been trying to figure this out for a while!
Re: rotate ?
Reply #1 - May 20th, 2009, 12:53pm
 
When you use translate() before rotate(), you move the point of rotation.

You might want to look into using push- and popMatrix() if you have several shapes.

http://processing.org/reference/pushMatrix_.html
http://processing.org/reference/popMatrix_.html
Re: rotate ?
Reply #2 - May 20th, 2009, 1:20pm
 
thanks a lot! it was very helpfull!
Re: rotate ?
Reply #3 - May 20th, 2009, 1:25pm
 
i've writen this code, and i cannot use rotate, it says that rotate isn't possible with this render, can somebody explain me why?

Code:


PShape s;
float xplus = 0.01;
float yplus = 0.01;

float xx = random(0, 0.05);
float yy = random(0, 10);
void setup(){

size(800,600);
frameRate(10);
}

void draw(){
float x = noise(xx)*width;
float y = noise(yy)*height;
xx += xplus;
yy += yplus;

String[] shapeNames = { "1.svg", "2.svg", "3.svg","4.svg", "5.svg", "6.svg", "7.svg", "8.svg", "9.svg","10.svg", "11.svg"};
PShape[] shapes = new PShape[shapeNames.length];
for (int s = 0; s < shapes.length; s++)

shapes[s] = loadShape(shapeNames[s]);


PShape shapeToDraw = shapes[int(random(shapes.length))];


float r = random(255);
float g = random(255);
float b = random(255);
float prop = random(150);
shapeToDraw.disableStyle();
noStroke();

float x2 = random(width);
float y2 = random(height);

fill(0,g,0,200);

shape(shapeToDraw, x,y);
ellipse(x2,y2,10,10);
pushMatrix();
float rot1 = random(5);
float rot2 = random(5);
float rot3 = random(5);
float rot4 = random(5);
rotate(rot1,rot2,rot3,rot4);
popMatrix();


}

Re: rotate ?
Reply #4 - May 20th, 2009, 2:10pm
 
you have 4 parameters to your rotate(). what are they for? (the documentation only shows one)

http://processing.org/reference/rotate_.html

"syntax: rotate(angle);"
Re: rotate ?
Reply #5 - May 20th, 2009, 2:53pm
 
If you want to rotate around an axis by a given angle, you would use rotateX(), rotateY(), or rotateZ() [if your sketch is in 3D] instead of passing several angles to rotate().
Re: rotate ?
Reply #6 - May 21st, 2009, 2:12pm
 
Check out the PeasyCam library.  Very easy way to manage the camera.
http://mrfeinberg.com/peasycam/
Page Index Toggle Pages: 1