Trouble with converting to openGL coordinate syst.

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.

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 :wink:

Jan.

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