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.
IndexDiscussionExhibition › Rotating Ellipse
Page Index Toggle Pages: 1
Rotating Ellipse (Read 2031 times)
Rotating Ellipse
Mar 20th, 2009, 5:53am
 
Ok, bear with me here, this is my first sketch I'm posting.  I lost a lot of hair to this one (had to remember a bit of my geometry from HS), anywho, here it is, please enjoy.. .

float fi = 0;
int ctrX;
int ctrY;

void setup() {
 size(150,150,P3D);
 ctrX = width/2;
 ctrY = height/2;
 background(0,0,0);
 stroke(0,0,0);
 fill(0,255,0);
}

void draw() {
 background(0,0,0);
 RotateEllipse();
}

void RotateEllipse() {
 if (fi > TWO_PI)  { fi = 0; }
 translate(ctrX,ctrY);  // center the ellipse in the window
 rotate(fi);
 // rotateX(fi);  // flipping top to bottom
 // rotateY(fi);  // flipping right to left
 // rotateZ(fi);  // spinning
 ellipse(sin(fi),cos(fi),60,10);
 fi = fi + 0.1;  // 0.01=crawl, 0.1=slow, 0.9=blur, 1.5=blur(x2)
}
Re: Rotating Ellipse
Reply #1 - Mar 21st, 2009, 1:14am
 
It looks very interesting.

But may i ask what is it for? Is it part of a project or just a proccessing experiment?

Re: Rotating Ellipse
Reply #2 - Mar 23rd, 2009, 7:35pm
 
It's part of a GUI for an RC submarine.  I needed a way to model the dive planes, and the sub itself, and using rotating lines was less than satisfying.

The GUI will use wireless Ethernet to connect to an arduino in the sub.
Re: Rotating Ellipse
Reply #3 - Mar 24th, 2009, 4:44pm
 
can someone explain why it looks so strange when I put smooth on?
Re: Rotating Ellipse
Reply #4 - Mar 24th, 2009, 5:30pm
 
Just look at the last paragraph of smooth() reference...
Re: Rotating Ellipse
Reply #5 - Mar 25th, 2009, 6:06pm
 
Arg!  When I have this part of the GUI, all the shapes rotate!  Does anyone know how to unrotate, or to turn rotate off?


> ah, if I put this line : rotate(-fi);
> after the ellipse, it allows other shapes to not rotate.
Re: Rotating Ellipse
Reply #6 - Mar 26th, 2009, 12:07pm
 
look at pushMatrix and popMatrix

http://processing.org/reference/pushMatrix_.html
http://processing.org/reference/popMatrix_.html

pushMatrix, rotate, draw your ellipse, popMatrix...
Re: Rotating Ellipse
Reply #7 - Mar 26th, 2009, 9:43pm
 
The push/pop Matrix stuff only works if you push onto the stack, or pull/pop off the stack in the exact same order, and has a limit of 32 "pushes".  The rotating ellipse, with an open step, can have 360 (or more) variations.  Maybe I'm not understanding the theory behind stacks.
Re: Rotating Ellipse
Reply #8 - Mar 27th, 2009, 1:05am
 
Quote:
Maybe I'm not understanding the theory behind stacks.

I think so too...  Grin
The idea is that inside a draw() call, you push before rotating a shape, do your transformations, draw the shape, then pull. And you do that for each shape needing transformations independently of the others.
No need, in general, to stack these calls.
Re: Rotating Ellipse
Reply #9 - Mar 27th, 2009, 9:26pm
 
Thank you!  That makes more sense.  I'm self learning on this, as such, am a bit slower than the average bear. Smiley
Page Index Toggle Pages: 1