FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Programs
(Moderators: fry, REAS)
   translate() the translate()?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: translate() the translate()?  (Read 429 times)
kevinP

Email
translate() the translate()?
« on: Jan 29th, 2004, 11:41pm »

I'm beginning to get comfortable with translate(), etc. and can rotate objects now, etc. I also understand the idea behind the push/pop stack.
 
But I need a tip here. I'd like to create a planetary motion with a "moon". So larger object A is orbiting about a center point; at the same time a smaller object B is orbiting around object A.
 
So it seems that for object B, the translate() matrix needs to know where object A is (which I don't know how to do)... or is this simply a nested sort of thing?
 
Thinking aloud... I _do_ know the angle of rotation for object A, so I should be able to calculate its absolute position by using object A's centerpoint, the angle of rotation, and the radius from centerpoint to object A...
 
http://www.tiros.net/pfeiffer/processing/misc/planet.gif
 
-K
« Last Edit: Mar 20th, 2004, 1:38am by kevinP »  

Kevin Pfeiffer
benelek

35160983516098 WWW Email
Re: transform the transform?
« Reply #1 on: Jan 30th, 2004, 1:41pm »

ah... you seem to be getting the hang of it - here's an example of how to do it. i hope my having given it to you doesn't take the fun out of the exercise!
 
Code:
float r1, r2;
 
void setup() {
  size(300,300);
  noFill();
  ellipseMode(CENTER_DIAMETER);
}
 
void loop() {
  background(255);
  stroke((int)random(255));
   
  translate(width/2,height/2,0); //move to centre of screen.
  rotate(r1); //rotate by first orbit.
  line(0,0,100,0);
  ellipse(100,0,10,10);
  translate(100,0); //move 100 along rotation.
  rotate(r2); //rotate by second orbit.
  line(0,0,50,0);
  ellipse(50,0,10,10);
   
  r1+=0.02;
  r2+=0.05;
}
 
kevinP

Email
Re: transform the transform?
« Reply #2 on: Jan 30th, 2004, 1:49pm »

Actually I was just thinking that I would delete my query because I think I have an idea now....
 
I'll give it one more go and then jump back to your answer (thanks for the help).
 
-K
 

Kevin Pfeiffer
mKoser

WWW Email
Re: transform the transform?
« Reply #3 on: Jan 30th, 2004, 4:28pm »

jakob, whats up with the...
Code:

stroke((int)random(255));

 
at first (without looking at the code) i thougt there was something strange going on with the rendering?
 
 

mikkel crone koser | www.beyondthree.com | http://processing.beyondthree.com
kevinP

Email
Re: translate() the translate()?
« Reply #4 on: Jan 30th, 2004, 7:53pm »

Here's what I finally came up with...
 
http://timo.iu-bremen.de/~pfeiffer/processing/2004/degrees_and_radians/
 
Attempted in the style of many of Casey's nice examples. It wasn't that complicated once I stopped and built a simplified model (similar to yours).
 
-K
 
(Finally corrected my subject line)
« Last Edit: Jan 30th, 2004, 8:09pm by kevinP »  

Kevin Pfeiffer
benelek

35160983516098 WWW Email
Re: translate() the translate()?
« Reply #5 on: Jan 31st, 2004, 1:49pm »

nice piece of interactive geometry Kevin, though it seems (to me) a little annoying having the angle of rotation measured from the centre, while the actual rotation occurs from the top left.
 
ah, mKoser... it was late and i was tired... flashing shades of grey to keep me awake
 
kevinP

Email
Re: translate() the translate()?
« Reply #6 on: Jan 31st, 2004, 2:00pm »

on Jan 31st, 2004, 1:49pm, benelek wrote:
nice piece of interactive geometry Kevin, though it seems (to me) a little annoying having the angle of rotation measured from the centre, while the actual rotation occurs from the top left.

 
I'm reading about Feynmann (with quantum theory's 'action at a distance').
 
I appreciate the comment; it's easy to lose one's perspective after a while. Probably not enough visual user feedback (which was why I added the point center screen). Maybe I'll have another go at it later.
 

Kevin Pfeiffer
Pages: 1 

« Previous topic | Next topic »