PDA

View Full Version : Need some help transforming coordinate systems



brett01
03-27-2010, 04:52 PM
Hi,

I have a coordinate system in xyz(local) format I want to transform into xzy(my world coordinate system) . Can someone give me the transform please.

Thanks & Regards
Brett,

trinitrotoluene
03-27-2010, 05:43 PM
If you want to swap the y and z coordinate, I think you have to rotate -90 degree around the x axis then scale the y axis by -1. Try that if it works:



//local to world coordinate transformation
glScalef(1.0,-1.0,1.0);
glRotatef(-90.0,1.0,0.0,0.0);
drawYourObject();


Edit: The scale must be aplied to the z axis(third coordinate).

brett01
03-27-2010, 06:31 PM
If its a normal I have to do the same ??

trinitrotoluene
03-27-2010, 07:14 PM
If its a normal I have to do the same ??

If you do your transformation via the OpenGL matrix stack, the normal will be transformed automatically for you. But the transformation of vertices is different of the transformation of normals. See this link (http://glprogramming.com/red/appendixf.html#name1) for more information.

brett01
03-27-2010, 07:40 PM
Thank you very much. I am not using opengl matrix stack I am using openscenegraph so I have the multiply my normal with inverse transpose of the the transformation matrix right ? Since, There is non uniform scale going on ???

trinitrotoluene
03-28-2010, 07:11 AM
I have used OpenScenegraph and the normals was transformed automatically with fixed function pipeline (no use of shaders).