QQuaternion how to rotate only x and y??



  • Hi,

    i want to rotate only in x and y direction, but it does not work that good.

    float pitch, yaw, roll;
    m_rotation.getEulerAngles(&pitch, &yaw, &roll);
    pitch = (diff.y() * 0.5 + pitch);
    yaw = (diff.x() * 0.5 + yaw);
    std::cout << pitch << " - " << yaw << std::endl;
    m_rotation = QQuaternion::fromEulerAngles(pitch, yaw, roll);
    

    yaw works fine, but pitch does not. it is limited to [-90,90]. But if i move the mouse not only up/down, but a little sideway, it moves over that limit but does crazy things like jumping somewhere. And most times i get nan from pitch and yaw and the model is not displayed anymore.

    Any ideas why this happens, or how to rotate only in x/y direction using Quaternion??


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.