View Full Version : Trouble with converting to openGL coordinate syst.

03-29-2009, 02:37 PM
Hi, i have a robot that uses a different coordinate system than openGL does and i have great difficulties in converting this to the openGL coordinate system. I like to draw some static elements (which use the robot coordinates) into openGL. The robot coordinate system has +Z pointing upwards, +Y pointing to the left, +X pointing backwards. Help is appreciated with this problem.

03-29-2009, 03:06 PM
Well, simply swap / negate the coordinates from your robot, before you put them into gl.

The transformation should look like this:

(x, y, z) -> (-y, z, x)

It would be easiest to write a little helper function, to do this:

vec3 MakeGLCoord (vec3 v)
return (vec3 (-v.y, v.z, v.x));

Then you can render your stuff like this:

vec3 vRobotPos = ...
vec3 glPos = MakeGLCoord (vRobotPos);

glVertex3f (glPos.x, glPos.y, glPos.z);

Hope that helps you. Though i do not guarantee that i got the transformation correct ;)


03-29-2009, 11:01 PM
the OpenGL coordinate system is a right-hand system with

x pointing right
y pointing upward
z pointing toward you ( out of the screen )

so the coordinates form yours to OpenGL

x ( 1, 0, 0 ) -> x' ( 0, 0, -1 )
y ( 0, 1, 0 ) -> y' ( -1, 0, 0 )
z ( 0, 0, 1 ) -> z' ( 0, 1, 0 )

just like Jan have said