tags:

views:

64

answers:

4

So I am doing a lot of math and I am running into different things where the coordinate plane starts at zero at the bottom and goes up higher on the y axis.

However in my program it is the reverse. Zero is at the top of the screen and goes up and you go down the y axis.

I have been dealing with this by updating my math equations to compensate.

Is there an easier way?

A: 

Treat it as a scaling transform with a negative Y scale and roll it in with whatever other transforms you're applying? I'm assuming you're doing 3D work and have to do a lot of 4x4 matrix transforms.

EDIT: Referring to the Wikipedia article, I think the transform matrix will look like this:

1  0  0  0
0 -1  0  0
0  0  1  0
0  0  0  0
Mike D.
A: 

You could just refactor your transformations in the equations into a set of transform matrices.

Pierreten
A: 

Any "easier way" totally depends on what precisely you're doing. Are you doing mathematical modeling? 3D rendering? Simple GUI setup? If you're doing a lot of matrix transforms, you can roll the difference into a scale by -1 and translate the height of the page. If you're not, then changing your equations might be your best bet.

Asher Dunn
+2  A: 

I see you tagged it with openGL. I'm not exactly sure what you're doing here but in case you didn't realize you can change the up direction in the gluLookAt function, i.e.

gluLookAt(0.0,0.0,100.0,    // Camera position
    0.0,0.0,0.0,            // Camera direction
    0.0,1.0,0.0);           // Camera up direction

So this would have the camera up the Z-axis looking at the origin with the y increasing up the screen.

Rob Lourens