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 › Coordinate System
Page Index Toggle Pages: 1
Coordinate System (Read 949 times)
Coordinate System
Dec 3rd, 2009, 10:37pm
 
Is it possible to transform the coordinate system into a (0,0) on the bottom left system, and if so, is it further possible to make (0,0) wherever?
Re: Coordinate System
Reply #1 - Dec 3rd, 2009, 11:04pm
 
take a look at translate
http://processing.org/reference/translate_.html

there you can translate the origin of your matrix wherever you want.
But y still counts up going down, not up like you are maybe used to.
There has been some postings about that too.

but if it is just because you are unfamiliar with it and not because you really need to turn the coordinate system upside down. i would try to get used to it. Doesnt take long and is much easier when you work with other codes and the reference etc.
Re: Coordinate System
Reply #2 - Dec 3rd, 2009, 11:53pm
 
I thank you for your reply.

translate worked wonderfully, as for flipping it:

 background(0, 0, 1.0);
 pushMatrix();
 applyMatrix(1, 0, 0, 0,
             0, -1, 0, 0,
             0, 0, 1, 0,
             0, 0, 0, 1);
 translate(0, -480);
 drawboard();
 popMatrix();

Works wonderful.

Now your last part as to the reasoning behind this - it is both because it is easier to consider coordinates in this fashion, and I am used to a mac.

Another reason to do it is because I can Wink

Now the applyMatrix command did warn about slowness, may I assume that this doesn't matter in this particular case?

For reference purposes, the reflection matrix was obtained from: planetmath dot org /encyclopedia/DerivationOf2DReflectionMatrix.html  as
Quote:
| 1 0  |
| 0 -1 |

I just extended it to 4x4 by adding additional zeros and 1s on the diagonal.
Re: Coordinate System
Reply #3 - Dec 4th, 2009, 12:34am
 
iæfai wrote on Dec 3rd, 2009, 11:53pm:
Now the applyMatrix command did warn about slowness, may I assume that this doesn't matter in this particular case


Here is what the reference says about applyMatrix() :
Quote:
This is very slow because it will try to calculate the inverse of the transform, so avoid it whenever possible.


It means : try to use scale(), translate(), rotate() whenever it is possible, your sketch will run faster.
Re: Coordinate System
Reply #4 - Dec 4th, 2009, 12:38am
 
What I meant to say: In this case where I am using it once, only take a hit during the call, or does it have to apply this transformation matrix more than once after this call?
Re: Coordinate System
Reply #5 - Dec 4th, 2009, 1:35am
 
If it's in draw() it's running every frame...
Re: Coordinate System
Reply #6 - Dec 4th, 2009, 1:39am
 
You can use map() to transform arbitrary coordinates to Processing's coordinate system.
I just gave an example in How to Graph Eqautions.
Page Index Toggle Pages: 1