//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// Given 2 euler rotations find a quaternion describing the relative rotation from the old to the new rotation
irr::core::quaternion getRelativeRotation(const irr::core::vector3df& oldRotationEulerDeg, const irr::core::vector3df& newRotationEulerDeg)
{
irr::core::quaternion q1(oldRotationEulerDeg*irr::core::DEGTORAD);
irr::core::quaternion q2(newRotationEulerDeg*irr::core::DEGTORAD);
irr::core::quaternion qRel(q2*q1.makeInverse());
return qRel;
}
// Given an euler angle + a quaternion with a relative rotation do return an euler angle describing the combined absolute rotation
irr::core::vector3df applyRelativeRotation(const irr::core::vector3df& oldRotationEulerDeg, const irr::core::quaternion& relativeRotation)
{
// Add relative rotation
irr::core::quaternion qt(oldRotationEulerDeg*irr::core::DEGTORAD);
irr::core::quaternion qt2(relativeRotation*qt);
irr::core::vector3df rotateTarget;
qt2.toEuler(rotateTarget);
rotateTarget *= irr::core::RADTODEG;
return rotateTarget;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
irr::core::vector3df rotateAxesXYZToEuler(const irr::core::vector3df& oldRotation, const irr::core::vector3df& rotationAngles, bool useLocalAxes)
{
irr::core::matrix4 transformation;
transformation.setRotationDegrees(oldRotation);
irr::core::vector3df axisX(1, 0, 0), axisY(0, 1, 0), axisZ(0, 0, 1);
irr::core::matrix4 matRotX, matRotY, matRotZ;
if (useLocalAxes)
{
transformation.rotateVect(axisX);
transformation.rotateVect(axisY);
transformation.rotateVect(axisZ);
}
matRotX.setRotationAxisRadians(rotationAngles.X*irr::core::DEGTORAD, axisX);
matRotY.setRotationAxisRadians(rotationAngles.Y*irr::core::DEGTORAD, axisY);
matRotZ.setRotationAxisRadians(rotationAngles.Z*irr::core::DEGTORAD, axisZ);
irr::core::matrix4 newTransform = matRotX * matRotY * matRotZ * transformation;
return newTransform.getRotationDegrees();
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
...
/* in main cicle */
{
...
vector3df oldRotationEulerDeg = node_I
->getRotation();
vector3df newRotationEulerDeg = vector3df(tet*RADTODEG, 180+psi*RADTODEG, gam*RADTODEG);
//vector3df ROT = rotateAxesXYZToEuler(oldRotationEulerDeg, newRotationEulerDeg, true);
quaternion relativeRotation = getRelativeRotation(oldRotationEulerDeg, newRotationEulerDeg);
vector3df ROT = applyRelativeRotation(oldRotationEulerDeg, relativeRotation);
node_I->setRotation(ROT);
node_I->setPosition(vector3df(X, Y, Z));
node_I->updateAbsolutePosition();
...
}
try to load image on forum
on screenshot red line is the current speed vector.