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 › Translating single objects among multiple
Page Index Toggle Pages: 1
Translating single objects among multiple (Read 940 times)
Translating single objects among multiple
Nov 6th, 2009, 9:44am
 
I'd like to use translate and rotate on just a few lines that are being drawn amongst hundreds. Is there a simple way to do this?? It seems that translate changes the coordinate system for everything being drawn.
Re: Translating single objects among multiple
Reply #1 - Nov 6th, 2009, 11:21am
 
Look at pushMatrix() Smiley
Re: Translating single objects among multiple
Reply #2 - Nov 8th, 2009, 7:52am
 
I have looked at it, PhiLho, but it's not clear how I would use it in a method in which I use a for loop to draw 200 objects from an array of objects every frame, and I only want handful of them to translate . . .
Re: Translating single objects among multiple
Reply #3 - Nov 8th, 2009, 8:10am
 
How do you determine which ones you want to translate?  Presumably a condition...  So wrap the pushMatrix/popMatrix calls around the translation code within this condition.
Re: Translating single objects among multiple
Reply #4 - Nov 9th, 2009, 2:02am
 
OK - I've got it working now, thanks. I have a follow-up question, though: how can I rotate a two-dimensional object about its own axis (i.e. spin it). I've tried rotate(), but that rotates things about the axis of the entire grid, it seems.
Re: Translating single objects among multiple
Reply #5 - Nov 9th, 2009, 5:11am
 
IIRC you first need to translate() to the desired axis of rotation.  The problem with that is you would need to be using translate to position the object on screen.  Alternatively you can use trigonometry and write methods to rotate the local coordinates of the objects...

That's a bit of a rushed and not thought-through answer; but this is something that has been asked before so I'm sure you might find something more detailed if you do a search Wink
Page Index Toggle Pages: 1