Animation of rotation around axis using quaternions

Hi, everyone!
Very interesting how to create animation of rotation sprite3D using quaternions. The goal is to rotate an sprite3D in 90 degree increments around the axes x and y. Use classes RotateBy or RotateTo it,s not good idea for this task.
Maybe it’s someone else has already implemented?
Thanks a lot!

Hi.

I have created RotateGlobalBy action which extends from ActionInterval.
For example:

RotateGlobalBy* RotateGlobalBy::create(float time, Vec3 angles)
{
return new RotateGlobalBy(time, angles);
}

RotateGlobalBy::RotateGlobalBy(float time, Vec3 angles)
{
this->initWithDuration(time);
this->autorelease();

this->angles = angles;
}

RotateGlobalBy::~RotateGlobalBy()
{
}

void RotateGlobalBy::startWithTarget(Node* target)
{
ActionInterval::startWithTarget(target);

this->target = target;
this->rotation = this->target->getRotationQuat();
}

void RotateGlobalBy::update(float time)
{
auto rotation = this->rotation;

rotation *= Quaternion(this->target->getWorldToNodeTransform() * Vec3::UNIT_X, CC_DEGREES_TO_RADIANS(this->angles.x * time));
rotation *= Quaternion(this->target->getWorldToNodeTransform() * Vec3::UNIT_Y, CC_DEGREES_TO_RADIANS(this->angles.y * time));
rotation *= Quaternion(this->target->getWorldToNodeTransform() * Vec3::UNIT_Z, CC_DEGREES_TO_RADIANS(this->angles.z * time));

this->target->setRotationQuat(rotation);
}