Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QtSensors convert azimuth to angle
Forum Updated to NodeBB v4.3 + New Features

QtSensors convert azimuth to angle

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.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.
  • M Offline
    M Offline
    mariusmssj
    wrote on last edited by
    #1

    Hello,
    I am trying to make a compass application using QtSensors 5.0, I am able to get azimuth value from the compass but I can't seem to find a proper formula to convert azimuth into a rotation angle for an image of a compass needle. Would anyone have any idea of what formula I need to use to get a proper rotation angle?

    My code below

    @   property real readAz: 0
    

    property real angle: 0

    Compass {
        id: compass
        dataRate: 1
        active: true
    
        onReadingChanged: {
            readAz = reading.azimuth
            angle  = (readAz /(2*Math.PI))
            
            print("Compass: ", reading.azimuth) //for debug
            print("Angle: ", angle)             //for debug
            
            needle.update()
        }
    }@
    

    thank you

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gkroeger
      wrote on last edited by
      #2

      Not sure what angle you need, but azimuth is typically measured from North going clockwise. In typical cartesian graphics, angle is measure from the x-axis (East) going counterclockwise.

      So, North is an azimuth of 0, but an angle of 90 (PI/2). East is an azimuth of 90 (PI/2) but an angle of 0.

      So if that's what you mean, then the angle is 90-azimuth. If you want all angles to be positive, just add 360 (2*PI) to negative angles.

      Glenn

      1 Reply Last reply
      1

      • Login

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