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. Calculate eulerRotation for Node

Calculate eulerRotation for Node

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 547 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.
  • md2012M Offline
    md2012M Offline
    md2012
    wrote on last edited by
    #1

    Hi, i need a little help with something in my 3D project.
    I need something like a map ping to point to the center of my Sphere in my QtQuick3D project.
    I was able to locate the rotation responsible for rotating the Node object which is 'eulerRotation'.
    So here is the information that I have about my point on the surface of sphere:

    Node{
        position: calculatedPosition()
        eulerRotation{
            x: ?
            y: ?
            z: ?
        }
    
        //Properties
        property int radiusEarth: 1180
        property real latitude: 0
        property real longitude: 0
    
        Node {
            Image {
                anchors.centerIn: parent
                width: 200
                height: 200
                source: "qrc:/3DGlobe/textures/Hexagon_LightGreen.png"
            }
        }
    
        //Functions
        function calculatedPosition(){
            var latitude_rad = latitude * Math.PI / 180;
            var longitude_rad = longitude * Math.PI / 180;
    
            var zPos = radiusEarth * Math.cos(latitude_rad) * Math.cos(longitude_rad);
            var xPos = -radiusEarth * Math.cos(latitude_rad) * Math.sin(longitude_rad);
            var yPos = radiusEarth * Math.sin(latitude_rad);
    
            return Qt.vector3d(-xPos+5, yPos+5, zPos+5)
        }
    }
    
    
    kshegunovK 1 Reply Last reply
    0
    • md2012M md2012

      Hi, i need a little help with something in my 3D project.
      I need something like a map ping to point to the center of my Sphere in my QtQuick3D project.
      I was able to locate the rotation responsible for rotating the Node object which is 'eulerRotation'.
      So here is the information that I have about my point on the surface of sphere:

      Node{
          position: calculatedPosition()
          eulerRotation{
              x: ?
              y: ?
              z: ?
          }
      
          //Properties
          property int radiusEarth: 1180
          property real latitude: 0
          property real longitude: 0
      
          Node {
              Image {
                  anchors.centerIn: parent
                  width: 200
                  height: 200
                  source: "qrc:/3DGlobe/textures/Hexagon_LightGreen.png"
              }
          }
      
          //Functions
          function calculatedPosition(){
              var latitude_rad = latitude * Math.PI / 180;
              var longitude_rad = longitude * Math.PI / 180;
      
              var zPos = radiusEarth * Math.cos(latitude_rad) * Math.cos(longitude_rad);
              var xPos = -radiusEarth * Math.cos(latitude_rad) * Math.sin(longitude_rad);
              var yPos = radiusEarth * Math.sin(latitude_rad);
      
              return Qt.vector3d(-xPos+5, yPos+5, zPos+5)
          }
      }
      
      
      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @md2012 said in Calculate eulerRotation for Node:

      I need something like a map ping to point to the center of my Sphere in my QtQuick3D project.

      I don't understand what you're trying to achieve, please elaborate.

      I was able to locate the rotation responsible for rotating the Node object which is 'eulerRotation'.

      Use a Transform to rotate the node.
      https://doc.qt.io/qt-5/qml-qt3d-core-transform.html

      Just noticed this is QtQuick3D, so my comment is useless, disregard.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • md2012M Offline
        md2012M Offline
        md2012
        wrote on last edited by md2012
        #3

        Let's say we have 3D pin like this one:
        map_pin_3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_3014170_o.png
        And we need to put it on a sphere (Earth model).
        First thing we are going to need to calculate where to put our pin on the earth surface, which is now working perfectly using the above code.
        The problem is that the pin is not pointing to the center of the sphere and we are going to need some calculation for rotation as well.

        kshegunovK 1 Reply Last reply
        0
        • md2012M md2012

          Let's say we have 3D pin like this one:
          map_pin_3d_model_c4d_max_obj_fbx_ma_lwo_3ds_3dm_stl_3014170_o.png
          And we need to put it on a sphere (Earth model).
          First thing we are going to need to calculate where to put our pin on the earth surface, which is now working perfectly using the above code.
          The problem is that the pin is not pointing to the center of the sphere and we are going to need some calculation for rotation as well.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @md2012 said in Calculate eulerRotation for Node:

          The problem is that the pin is not pointing to the center of the sphere and we are going to need some calculation for rotation as well.

          You realize that this is an impossible task, right? Your system is underdetermined, that is even if the pin's butt is pointing away from the center (of your sphere) all rotations around the radius vector (or in the local coordinates, around the z-axis of the pin) are equally correct. You need more information - typically a vector to fix the actual orientation.

          Read and abide by the Qt Code of Conduct

          md2012M 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @md2012 said in Calculate eulerRotation for Node:

            The problem is that the pin is not pointing to the center of the sphere and we are going to need some calculation for rotation as well.

            You realize that this is an impossible task, right? Your system is underdetermined, that is even if the pin's butt is pointing away from the center (of your sphere) all rotations around the radius vector (or in the local coordinates, around the z-axis of the pin) are equally correct. You need more information - typically a vector to fix the actual orientation.

            md2012M Offline
            md2012M Offline
            md2012
            wrote on last edited by md2012
            #5

            Looks like latitude and longitudes were enough to calculate the right angle for the marker to point to the center of the sphere.
            Here is the final result:

            Node{
                position: calculatedPosition()
                eulerRotation{
                    x: 180-latitude
                    y: longitude
                    z: 0
                }
            
                //Properties
                property int radiusEarth: 1180
                property real latitude: 0
                property real longitude: 0
            
                Node {
                    Image {
                        anchors.centerIn: parent
                        source: "qrc:/3DGlobe/textures/Hexagon_LightGreen.png"
                    }
                }
            
                //Functions
                function calculatedPosition(){
                    var latitude_rad = latitude * Math.PI / 180;
                    var longitude_rad = longitude * Math.PI / 180;
            
                    var zPos = radiusEarth * Math.cos(latitude_rad) * Math.cos(longitude_rad);
                    var xPos = -radiusEarth * Math.cos(latitude_rad) * Math.sin(longitude_rad);
                    var yPos = radiusEarth * Math.sin(latitude_rad);
            
                    return Qt.vector3d(-xPos-10, yPos+10, zPos+10)
                }
            }
            
            

            My pointer is 2d so this could need a 180 degree rotation with a 3d pin.

            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