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. Using setCamera[XY]Rotation in Q3DScatterWidgetItem to move camera above a point
Forum Updated to NodeBB v4.3 + New Features

Using setCamera[XY]Rotation in Q3DScatterWidgetItem to move camera above a point

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 1 Posters 66 Views
  • 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.
  • G Offline
    G Offline
    gmbrown
    wrote last edited by
    #1

    I'm building a 3D scatter graph for a magnetometer calibration tool. The graph is centered on [0,0,0], I'd like to make sure the camera points through the most recent point (call it v) to [0,0,0].
    I'm struggling finding the right incantation. I'm not really sure how CameraXRotation and CameraYRotation should relate to the euler angles of v. Here's my latest effort (which doesn't work):

       QVector3D v = QVector3D(x,y,z);
        v.normalize();
    
        // camera vector
       
        QVector3D camera = QVector3D(0,1,0);  // camera along y axis
    
        // compute rotation
    
        QQuaternion rotation = QQuaternion::rotationTo(camera,v);
        rotation.getEulerAngles(&pitch,&yaw,&roll);
    
        // set camera rotation
        
        graph->setCameraXRotation(roll);
        graph->setCameraYRotation(pitch);
    
    1 Reply Last reply
    0
    • G Offline
      G Offline
      gmbrown
      wrote last edited by
      #2

      After much digging to understand how qtgraphs handles vectors, I did finally crack this. Camera direction is -z, coordinates are y-up. So X rotation angle is from yaw.

      QVector3D v = QVector3D(x,y,z);
      v.normalize();
      
      // camera vector
      
      QVector3D camera = QVector3D(0,0,-1);  // camera along z axis
      
      // compute rotation
      
      QQuaternion rotation = QQuaternion::rotationTo(camera,v);
      rotation.getEulerAngles(&pitch,&yaw,&roll);
      
      // set camera rotation
      
      graph->setCameraXRotation(yaw);
      graph->setCameraYRotation(pitch);
      
      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