# QtSensors convert azimuth to angle

• 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

angle  = (readAz /(2*Math.PI))

print("Compass: ", reading.azimuth) //for debug
print("Angle: ", angle)             //for debug

needle.update()
}
}@
``````

thank you

• 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