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 › Way to infer position on a translate(ed) space
Page Index Toggle Pages: 1
Way to infer position on a translate(ed) space? (Read 168 times)
Way to infer position on a translate(ed) space?
Mar 8th, 2009, 6:25pm
 
Hi, I've been using translate and rotate a lot recently and I was wonder if there was a way to get an unTranslated x,y location from a translated point. There are ways to figure this out by running some of the translation math but it gets sticky and confusing at best.

for example:

Quote:
ellipse(0,0,50,50);
translate(300,0);
rotate(.25*PI);
translate(300,0);
ellipse(0,0,50,50);
//Where is the second ellipse according to the grid of the first?



A simple move such as this would be easily possible assuming i broke down the rotated translation into X and Y vectors, but after 10 or 20 steps like this that sort of thing becomes a headache.


In short, is there a function I can run that will tell me the relative position of my translated 0,0 compared to the starting 0,0? That is to say if I held my mouse over the second ellipse, what would mouseX and mouseY be?

Thanks!
Re: Way to infer position on a translate(ed) space
Reply #1 - Mar 8th, 2009, 7:11pm
 
You want: http://processing.org/reference/screenX_.html (and screenY)
Re: Way to infer position on a translate(ed) space
Reply #2 - Mar 8th, 2009, 10:55pm
 
Re: Way to infer position on a translate(ed) space
Reply #3 - Mar 9th, 2009, 2:54am
 
OMG, thanks!

This is most helpful.
Page Index Toggle Pages: 1