Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void computeOrientation() {
- if (SensorManager.getRotationMatrix(m_rotationMatrix, null,
- m_lastMagFields, m_lastAccels)) {
- SensorManager.getOrientation(m_rotationMatrix, m_orientation);
- /* 1 radian = 57.2957795 degrees */
- /* [0] : yaw, rotation around z axis
- * [1] : pitch, rotation around x axis
- * [2] : roll, rotation around y axis */
- float yaw = m_orientation[0] * 57.2957795f;
- float pitch = m_orientation[1] * 57.2957795f;
- float roll = m_orientation[2] * 57.2957795f;
- /* append returns an average of the last 10 values */
- m_lastYaw = m_filters[0].append(yaw);
- m_lastPitch = m_filters[1].append(pitch);
- m_lastRoll = m_filters[2].append(roll);
- TextView rt = (TextView) findViewById(R.id.roll);
- TextView pt = (TextView) findViewById(R.id.pitch);
- TextView yt = (TextView) findViewById(R.id.yaw);
- yt.setText("azi z: " + m_lastYaw);
- pt.setText("pitch x: " + m_lastPitch);
- rt.setText("roll y: " + m_lastRoll);
- }
- }
- if (SensorManager.getRotationMatrix(m_rotationMatrix, null,
- m_lastAccels, m_lastMagFields)) {
Add Comment
Please, Sign In to add comment