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 › getting coords from matrix stack transform
Page Index Toggle Pages: 1
getting coords from matrix stack transform? (Read 513 times)
getting coords from matrix stack transform?
May 22nd, 2008, 6:42am
 
Hi there, my first post im rather new to processing and matrices.

Is there a way to get the new location of a point from a matrix stack ?
in the case of rotating a 2d polygon.

pushMatrix();
translate(center.x,center.y);
rotate(spin);
// looking for some way to store the transformed XY or XYZ coordinate here

for (int i=0; i<list.size(); i++) {
point pxy = (point) list.get(i);
pxy[i].x= transformed x;
pxy[i].y= transformed y;
}
popMatrix();

Or would one have to re-solve for this. Would seem to be unnecessary since the matrix stack should contain the information because it has solved the transform.
Re: getting coords from matrix stack transform?
Reply #1 - May 22nd, 2008, 9:41am
 
I think http://processing.org/reference/screenX_.html (and screenY) are just what you're looking for, they'll tell you where about on screen a certain x/y/z coordinate will appear.
Re: getting coords from matrix stack transform?
Reply #2 - May 22nd, 2008, 10:36am
 
Sweet thnx john. silly me.
Re: getting coords from matrix stack transform?
Reply #3 - May 22nd, 2008, 1:11pm
 
what a handy command!

does it take account of camera transformations too?
Re: getting coords from matrix stack transform?
Reply #4 - May 22nd, 2008, 1:19pm
 
It'll tell you were an x/y/z point will appear on screen given all the current transformations, both camera and scene.
Re: getting coords from matrix stack transform?
Reply #5 - May 22nd, 2008, 4:22pm
 
Crikes, that just saved me tons of time!  But the question is...is screenZ() about the projected image, or I should know something about my otherwise 2D monitor? Smiley
Re: getting coords from matrix stack transform?
Reply #6 - May 22nd, 2008, 4:44pm
 
screenZ() gives the z-buffer value I think.
Page Index Toggle Pages: 1