summaryrefslogtreecommitdiff
path: root/examples/sensors/accelbubble
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sensors/accelbubble')
-rw-r--r--examples/sensors/accelbubble/accelbubble.qml6
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/sensors/accelbubble/accelbubble.qml b/examples/sensors/accelbubble/accelbubble.qml
index 37bf427..8bd036f 100644
--- a/examples/sensors/accelbubble/accelbubble.qml
+++ b/examples/sensors/accelbubble/accelbubble.qml
@@ -63,7 +63,7 @@ ApplicationWindow {
width: 320
height: 480
visible: true
-
+ readonly property double radians_to_degrees: 180 / Math.PI
//! [1]
Accelerometer {
@@ -101,10 +101,10 @@ ApplicationWindow {
}
function calcPitch(x,y,z) {
- return -(Math.atan(y / Math.sqrt(x * x + z * z)) * 57.2957795);
+ return -Math.atan2(y, Math.hypot(x, z)) * mainWindow.radians_to_degrees;
}
function calcRoll(x,y,z) {
- return -(Math.atan(x / Math.sqrt(y * y + z * z)) * 57.2957795);
+ return -Math.atan2(x, Math.hypot(y, z)) * mainWindow.radians_to_degrees;
}
Image {