For motion computing, coordinate frames are used to describe the position or motion of a mobile device in a three dimensional space. For instance, MotionStack.Gyroscope measures the angular velocity of a rotating mobile device by sensing how quickly it is rotating along each of the three axes of the device. MotionStack.Accelerometer works in a similar way, except that it measures acceleration along each axis. There are two important standard coordinate frames concerning motion computing: the device frame and the world frame. An additional coordinate frame, the user frame, is also built into MotionStack and is described below.
The device frame, as the name suggests, fixes the axes of the coordinate frame to the device, as shown in the image below. This is the default coordinate system for measuring motion on a mobile device. On a mobile phone, the device frame is configured to have the positive x-axis pointing out of the right side of the device, the y-axis points out the top of the device, and the z-axis points out of the device screen. This setup means that as the device moves, the axes of the device frame move too. In most cases, the axes rotate to stay consistent as the screen between landscape and portrait orientations. (As a warning, the axial configuration on tablets is specific to the implementation of the browser.)
The world frame is a coordinate frame that is independent of the angular attitude of the mobile device. It is configured so that the z-axis always points in the opposite direction to the force of gravity, which is measured by the accelerometer. The y-axis in the world frame is orthogonal to the z-axis and points toward magnetic north as measured by the compass. Finally, the x-axis is orthogonal to both the y and z axes and points so that it makes forms a right-handed coordinate system. The image depicts several mobile devices at distinct attitudes, but the world frame coordinate system is the same between all devices.
Calibration Issues and the Relative World Frame
As mentioned above, the y-axis of the world frame points north and is orthogonal to the direction of gravity. However, due to magnetometer calibration issues, the direction of north is often measured innaccurately or can be corrupted by nearby electronics. To avoid this issue, readings from the magnetometer are ignored and the relative-world frame - also called the game frame - is used.
Heading in the relative-world frame is measured as the offset from the initial attitude of the device, rather than the offset from north. Due to the improved stability of the relative-world frame, the term world frame generally refers to the relative-world frame and the term absolute world frame is used to specify that the coordinate system respects north.
The user frame is a reference frame fixed to the user. The user is aware of the direction forward, the direction to the right side, and the downward direction (gravity). We mimic this frame by taking a combination of the device-frame and world-frame. This frame assumes the user is holding the device in portrait mode at a comfortable viewing angle in front of themself.
The positive x-axis of the user frame points out the right side of the device. The positive y-axis points upward, opposite to the direction of gravity. The positive z-axis points toward the user in the direction orthogonal to the x- and y-axes.
The device and world coordinate frames are distinct; but the device coordinate frame can be rotated so that all three of its axes align with those of the world frame. This rotation is described by the output of MotionStack.Orientation, which provides a quaternion description as well as the Tait-Bryan angles for measuring the offset of the device frame axes to the world frame axes.