Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rotations with QQuaternion and QSlider
Forum Updated to NodeBB v4.3 + New Features

Rotations with QQuaternion and QSlider

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    basil_fawlty
    wrote on last edited by
    #1

    I have implemented an Objectrotation with QQuaternion and QPushButton.
    As long as the plus_x_button is pushed the slot rotate_plus_x() is activated.
    Respectively for minus_x.

    @
    void OpenGLScene::rotate_plus_x()
    {
    OpenGLScene::anglex = 2;
    test->rotation *= QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
    update();
    }

    void OpenGLScene::rotate_minus_x()
    {
    OpenGLScene::anglex = -2;
    test->rotation *= QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
    update();
    }
    void OpenGLScene::rotate_plus_y(){...}
    void OpenGLScene::rotate_minus_y(){...}

    void OpenGLScene::rotate_plus_z(){...}
    void OpenGLScene::rotate_minus_z(){...}
    @

    Now I would like to realize the functionality with a Qslider instead of the QPushButton.
    With a range between -180° and 180°
    But then I have the problem that I get weird outcomes because the value of the Qslider is changed and the QQuaternion expexts a nonchangeble angle.
    Have you an idea how to achieve that? I have tried it with if-statements.
    Something like:

    @
    if(slidervalue<0)
    {
    OpenGLScene::anglex = -2;
    test->rotation *= QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
    }
    else
    {
    OpenGLScene::anglex = 2;
    test->rotation *= QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
    }
    @

    Unfortunately its not working. Do you have an idea, how to achieve that?

    Thank you

    1 Reply Last reply
    0
    • B Offline
      B Offline
      basil_fawlty
      wrote on last edited by
      #2

      I have now the answer:

      Instead of this:
      @
      test->rotation *= QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
      @
      I have to write this
      @
      test->rotation = QQuaternion::fromAxisAndAngle(QVector3D(1,0,0),OpenGLScene::anglex);
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved