Andreas Goebel schrieb:

Matthias Ferch schrieb:

in my app, the user can enter 3 angles in degrees (float AngleX, AngleY, AngleZ) in text controls to set the rotation of a PositionAttitudeTransform. the entered values are then processed like this:

float qx = (AngleX*PI)/180.0f;
float qy = (AngleY*PI)/180.0f;
float qz = (AngleX*PI)/180.0f;

MeshTransform->setAttitude( Quat(qx, Vec3(1.0f, 0.0f, 0.0f), qy, Vec3(0.0f, 0.0f, 1.0f), -qz, Vec3(0.0f, 1.0f, 0.0f)) );

the user can alternativly simply rotate the PositionAttitudeTransform with the mouse. so i need to get the updated rotation values to update my text controls. my question is now, how can i extract these values back from the transform (in degrees)? yeah i suck at maths :D
thanks in advance!
_______________________________________________


Hi,

it´s not that easy and no shame to ask.
I have the nice book "Geometric toosl for computer graphics", and there is the following solution: - convert the quat to a matrix. Lets assume your matrix is r00, r01, r02 (first row), r10, r11, r12 (second row) and so on (convert this to your needs)

thetaY = asin(r02);
if (thetaY < PI/2.0) {
if (thetaY > -PI /2.0) {
thetaX = atan2(-r12, r22);
thetaZ = atan2(-r01, r00);
} else{
//solution is not unique!
thetaX = -atan2(r10, r11);
thetaZ = 0;
}
}else{
thetaX = atan2(r10, r11);
thetaZ = 0;
}

atan2 is defined in math.h

Please let me know if it works. You will have to calculate back the values do degrees, of yourse. The solution is not unique, and I don´t know if you have the ordering x, y, z.

Regards,

Andreas

oha ok, thank you! one problem though, i created a matrix from the quat, but how can i access the members of a matrix in osg? the [] operator is not defined..
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to