• Advertisement
Sign in to follow this  

Converting Screen-Space Coordinates to Real-World Coordinates

This topic is 2632 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I am working on an application for Android - what we need is for the output of the Accelerometer to be transformed by the orientation of the device.

There are two sensors: Accelerometer and Orientation.

Accelerometer returns (in screen-space)... acceleration for X, Y, and Z.
Orientation returns angles for X, Y, and Z.

Screen-Space to Android seems to be equivalent to Object-Space. If I push the phone 'forward' from the top of it, it will show acceleration with Y = acceleration.

My thought: I need to convert the output from the orientation into a vector, which will give me the Y vector (forward) (ignoring z):

vec.x = Math.cos(x) * Math.cos(y);
vec.y = Math.sin(x) * Math.cos(y);
vec.z = Math.sin(y);

From there, am I correct in that I would need to generate a rotation matrix (equivalent to a modelview matrix), from which I would rotate the acceleration vector given by the acceleration sensor?

Basically, I want to cancel out the affect of rotation on the device - gravity should (though wouldn't due to errors) always show as Z = -G, but as is the acceleration is affected by rotation (as it is in screenspace/object space).

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement