To understand how to visualize the data we get from the device sensors, look at the image below.Form Android DevelopersWhen a device is held in its default orientation, the X axis is horizontal and points to the right, the Y axis is vertical and points up, and the Z axis points toward the outside of the screen face.In our case the accelerometer gives us the value relative to this coordinate system and it will be difficult to understand how the action happened in the real world..We can easily achieve that with this method provided by the SensorManager class.SensorManager.getRotationMatrixFromVector(rotationMatrix, quaternion)Finally, to transform our data from the relative coordinate system to the earth absolute coordinate system is pretty straightforward: we just need to rotate the vector (in our case the accelerometer values) by the rotation matrix and this is it.vector = LinearAlgebraHelper.rotateVector3(vector, rotationMatrix)In linear algebra, a rotation matrix is a matrix that is used to perform a rotation in Euclidean space.Lets’ jump to the implementation of the rotateVector3 method with the rotation matrix (a simple matrix-vector multiplication):// v: vector we want to rotate, r: rotation matrixfun rotateVector3(v : FloatArray, r: FloatArray): FloatArray { val newVector = FloatArray(3) for(i in 0..2) { var s = 0f for(j in 0..2) { s += vector[j] * rotationMatrix[j+i*3] } newVector[i] = s } return newVector }Now everything is setup and ready to be tested, feel free to experiment with the git repository and leave your feedback.Here are some links I found useful during my studies:Android Developers — SensorsRotate vector — rotation matrixRotation Matrix — WikipediaQuaternionsQuaternion — 3 blue 1 brownRotate vector3 by quaternionQuaternions – Wikipedia. More details