PDA

View Full Version : xyz, xzy?



Bagoj
09-04-2002, 01:06 AM
Hi there!

I'm a little confused about dimensions and angles in openl space. Can anyone help me how to set up that z shold be pointing up (ok i can swap y, and z but its ugly) and the angle 0 is pointing to x+ and if i go counter clockvise 90 degrees it turns to y+. Or how you guys do it? I'm having troubles using sin and cos, can anyone tell me a perfect solution, please. Of coures i done it my way like glTranslatef(-heading + 90, ... but it looks disgusting, any other solutions? Thanks, and sorry for my poor english

witcomb
09-04-2002, 03:16 AM
Hmm, well you could just rotate about the x-axis by 90 degrees. This will have the x-axis pointing to the left, y-axis pointing in to the screen, and z-axis pointing up. Hence, glRotatef(90,1,0,0). Is this not all you need???

You mentioned you could just swap the y-axis and z-axis. By doing this you would be converting from a right handed system to a left handed system, which you probably don't want to do. However, if you would insist you can try using glLoadMatrix with the following matrix:

[ 1 0 0 0 ]
[ 0 0 1 0 ]
[ 0 1 0 0 ]
[ 0 0 0 1 ]

This should do the job of swapping the y-axis and z-axis.

Neil Witcomb

nexusone
09-04-2002, 03:58 AM
Why do you want to have Z axis point up?
Are you working on something like a top view game?


You may find trouble doing something other then the standerd XYZ system, since all examples and tutors use the XYZ system.

The best way is just to rotate you axis to make Z axis up/down.


Originally posted by Bagoj:
Hi there!

I'm a little confused about dimensions and angles in openl space. Can anyone help me how to set up that z shold be pointing up (ok i can swap y, and z but its ugly) and the angle 0 is pointing to x+ and if i go counter clockvise 90 degrees it turns to y+. Or how you guys do it? I'm having troubles using sin and cos, can anyone tell me a perfect solution, please. Of coures i done it my way like glTranslatef(-heading + 90, ... but it looks disgusting, any other solutions? Thanks, and sorry for my poor english

Bagoj
09-04-2002, 05:37 AM
Neil, do you mean i should use that matrix rather then calling glLoadIdentity?
Actually it's not as big problem as it seems to me, because i have the program already running just with things i wrote (glRotatef(-heading + 90, 0, 1, 0) etc.) i just want the code look better. I'll try that matrix, thanks a lot!

witcomb
09-04-2002, 06:20 AM
You say that you have things working while rotating about the y-axis by 90 degrees, but this is now what you described as wanting. You said you would like to have the z-axis pointing upwards, rotating about the y-axis will not do this for you. Instead this will have the x-axis pointing either in/out of the screen and the z-axis pointing either left/right depending on the direction of rotation.

As for doing the load instead of the identity, yes you can do this instead. I would normally just set the identity and then multiply but either method will work the same. I must be curious however, why would you want to make this modification? If things are working with the coordinate system that you are using now, why change it?

Neil Witcomb

Bagoj
09-04-2002, 07:06 AM
float identityMatrix[16] = {0,0,-1,0, -1,0,0,0, 0,1,0,0, 0,0,0,1}; That is what i wanted to do, z+ pointing up, the angle 0 pointing to x+ and when turning counter clockwise it goes to y+. I need it for my trigonomety calculations, some of those are now seriously complicated and i can not see now which axis goes where. I just wanted cos(alpha) to give me the x value and sin(alpha) the y value without thinking on that it is now y or -y or z or what. Now i dont'n need that **** -heading + 90 and swaping z and y, now just glRotatef(heading, 0,0,1) http://www.opengl.org/discussion_boards/ubb/redface.gif) cool, thank you very much for your help, and sorry, sometimes i do not write exacly what i want to, i'm still learning english http://www.opengl.org/discussion_boards/ubb/redface.gif(