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 & HelpOther Libraries › geometric transformations
Page Index Toggle Pages: 1
geometric transformations (Read 348 times)
geometric transformations
Aug 7th, 2008, 4:31am
 
Hello all,
I am new to processing and I'd like a hint regarding a problem. I am drawing an image on the canvas(let's say at point (100,200)). This is the upper-left origin of my image on the canvas. From this I can deduce the lower-left, upper-right and lower-right coordinates based on the width and height of my image. All fine till there although I would expect there to be a method to give me these values directly. The real problem occurs when I rotate my image on the canvas. After applying a rotation to the image I can no longer deduce my x/y coordinates by simply adding the width and height of the image to my root coordinates. What I want to know is whether there is an easy way of getting the x/y coordinates of the image on all corners directly or do I have to apply a transformation matrix myself to my original coordinate matrix of the image to get these new values?

In other words is there anyway to know the image.topleft, image.topright, image.lowerleft, image.lowerright coordinates directly or do I have to always deduce these myself according to the transformations I apply on the image?
Re: geometric transformations
Reply #1 - Aug 7th, 2008, 9:47am
 
You can use screenX and screenY and give the various offsets to the upper left, and they'll tell you where on screen any particular point is.

e.g.
Code:

translate(200,200);
rotate(0.323);
translate(-50,-10);
float upperLeftX=screenX(0,0,0);
float upperLeftY=screenY(0,0,0);
float upperRightX=screenX(img.width,0,0);
float upperRightY=screenY(img.width,0,0);
//etc, etc...
Page Index Toggle Pages: 1