PDA

View Full Version : coordinating system



eleanor
7th November 2007, 01:04
Hi. I want to implement the coordinate system like in math where there would be a rectangle with 4 corners:
- the first corner would be (0,0) --> left+down
- the second --> (0,1) --> right + down
- third --> (1,0) --> left + up
- forth --> (1,1) --> right + up
----> that is what the coordinate system looks like in math

But in programming it's not like that. I need a way to make this possible. Any ideas?

I'm using QPainter class. I tried like this:



//move the coording system to the (WIDTH,HEIGHT)
painter.translate(WIDTH,HEIGHT);
//rotate the coordinating system for 180 degrees
painter.rotate(180);
//sets the painter's window to the rectangle beginning at (x, y) and the given width and height.
painter.setWindow(0,0,WIDTH,HEIGHT);

but it's not exactly what I want...

I need some suggestions how to make this possible.

jacek
7th November 2007, 01:12
painter.rotate(180);
Unfortunately this won't work, you have to flip the Y axis using scale( -1, 1 ).

eleanor
7th November 2007, 01:40
Can you be more specific, I don't know what you mean.

And I've tried painer.scale(-1,1) and doesn't help with my problem?

jacek
7th November 2007, 21:57
You need:
painter.setWindow( 0, 0, WIDTH, HEIGHT );
painter.scale( 1.0, -1.0 );
painter.translate( 0.0, -HEIGHT );