PDA

View Full Version : How to interchange glTranslate - glRotate



carla_sch
02-16-2013, 01:18 AM
I want to interchange the order of rotation and translation.
This is the original:

glRotated(angle,0.0,0.0,1.0);
glTranslated(x0,y0,z0);


And this is the changed version that should be the exactly identical transformation:

glTranslated(x1,y1,z1);
glRotated(angle,0.0,0.0,1.0);

Does anyone know the formula, how to calculate x1 y1 z1 from x0 y0 z0 and angle ?
I need this to combine two translations that almost cancel and produce rounding errors.

Aleksandar
02-16-2013, 02:40 AM
You need to solve a system of linear equations:
T(v1)*R(a) = R(a)*T(v0) => T(v1) = R(a)*T(v0)*R(a)^-1