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 & HelpSyntax Questions › accumulated rotation value
Page Index Toggle Pages: 1
accumulated rotation value (Read 724 times)
accumulated rotation value
Aug 12th, 2007, 5:50pm
 

Hi,

Can anyone tell me how to make rotations not accumulate?

for example:


void draw()
{
line_one();
line_two();
line_three();
}

void line_one()
{
rotateX(a value);
line(x1, y1, z1, x2, y2, z2);
}

 void line_two()
 {
  rotateX(a value);
  line(x1, y1, z1, x2, y2, z2);
 }

   void line_three()
   {
    rotateX(a value);
    line(x1, y1, z1, x2, y2, z2);
   }

When I do this, line two rotates at 2 x (a value), and line three rotates 3 x (a value), and so forth...

I also used pushMatrix, translate and popMatrix functions in each 'void line()', but the result is the same.

What do you think I am missing?

Thanks,

Emre.

Re: accumulated rotation value
Reply #1 - Aug 12th, 2007, 10:07pm
 
Edit!

pushMatrix() and popMatrix() is the way to go..
maybe you used them wrong


example:

void line1()
{
pushMatrix();
rotate();
render();
popMatrix();
}

void line2()
{
pushMatrix();
rotate();
render();
popMatrix();
}
Re: accumulated rotation value
Reply #2 - Aug 16th, 2007, 11:44pm
 

thanks a lot !
Re: accumulated rotation value
Reply #3 - Aug 27th, 2007, 12:53pm
 
or just do

void line_one()
{
rotateX(a value);
line(x1, y1, z1, x2, y2, z2);
rotateX(-a value);
}
Page Index Toggle Pages: 1