Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3455244
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:35:26+00:00 2026-05-18T09:35:26+00:00

When I listen to orientation event in an android app, I get a SensorEvent,

  • 0

When I listen to orientation event in an android app, I get a SensorEvent, which contains 3 floats – azimuth, pitch, and roll in relation to the real-world’s axis.

Now say I am building an app like labyrinth, but I don’t want to force the user the be over the phone and hold the phone such that the xy plane is parallel to the ground. Instead I want to be able to allow the user to hold the phone as they wish, laying down or, perhaps, sitting down and holding the phone at an angle. In other words, I need to calibrate the phone in accordance with the user’s preference.

How can I do that?

Also note that I believe that my answer has to do with getRotationMatrix and getOrientation, but I am not sure how!

Please help! I’ve been stuck at this for hours.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:35:27+00:00Added an answer on May 18, 2026 at 9:35 am

    For a Labyrinth style app, you probably care more for the acceleration (gravity) vector than the axes orientation. This vector, in Phone coordinate system, is given by the combination of the three accelerometers measurements, rather than the rotation angles. Specifically, only the x and y readings should affect the ball’s motion.

    If you do actually need the orientation, then the 3 angular readings represent the 3 Euler angles. However, I suspect you probably don’t really need the angles themselves, but rather the rotation matrix R, which is returned by the getRotationMatrix() API. Once you have this matrix, then it is basically the calibration that you are looking for. When you want to transform a vector in world coordinates to your device coordinates, you should multiply it by the inverse of this matrix (where in this special case, inv(R) = transpose(R).

    So, following the example I found in the documentation, if you want to transform the world gravity vector g ([0 0 g]) to the device coordinates, multiply it by inv(R):

    g = inv(R) * g

    (note that this should give you the same result as reading the accelerometers)

    Possible APIs to use here: invertM() and multiplyMV() methods of the matrix class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would I listen for orientation change in Android? and do certain things when
/* listen for the submit button press */ YAHOO.util.Event.addListener(webserver.result_form, 'submit', webserver.result_submit); I have this
I tried to listen file change event in BlackBerry base on FileExplorer example, but
I would like to listen for the mouse over event in GWT 1.6. Since
Say if I listen for an event: Subject.NewEvent += delegate(object sender, NewEventArgs e) {
How do I listen to click event on a ListView? This is what I
I need to listen to a network broadcast coming over UDP. The datagram contains
I have an activity who's orientation is locked to portrait: <activity android:name=MainActivity android:label=@string/app_name android:screenOrientation=portrait
Is it possible simple to detect current orientation of android device, without programming a
I have a custom ListView in which each row.xml looks like this: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.