Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old March 6th, 2010, 02:54 PM   #1 (permalink)
New Member
 
Join Date: Mar 2010
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accelerometer results translation from phone to word orientation

Hi,
I have a problem with the translation of the accelerometer results
from the phone to the world orientation.
The Z results seem OK but the X and Y get wrong values.
It was tested in horizontal phone move.
Attached is the code.
public void onSensorChanged(SensorEvent event) {
synchronized (this) {
// Log.d("MotionTest", "sensor: " + sensor + ", x: " + values[0] +
", y: " + values[1] + ", z: " + values[2]);
int type = event.sensor.getType();
if(type == Sensor.TYPE_ACCELEROMETER) {
acceleValues = event.values.clone();
} else if (type == Sensor.TYPE_MAGNETIC_FIELD) {
magnetValues = event.values.clone();
} else if (type == Sensor.TYPE_ORIENTATION) {
orientValues = event.values.clone();
}
SensorManager.getRotationMatrix(mR, mI,
acceleValues ,magnetValues);
// SensorManager.getOrientation(mR, orientValues);
acceleEarthValues[0]=mR[0]*acceleValues[0]+mR[1]*acceleValues[1]+mR[2]*acce leValues[2];
acceleEarthValues[1]=mR[3]*acceleValues[0]+mR[4]*acceleValues[1]+mR[5]*acce leValues[2];
acceleEarthValues[2]=mR[6]*acceleValues[0]+mR[7]*acceleValues[1]+mR[8]*acce leValues[2];
}
drawData();
}
The mR and mI are defined as:
private float[] mR = new float[9];
private float[] mI = new float[9];
Please advice
Thanks
Ofer

ofer is offline  
Reply With Quote
Sponsors
Reply

Bookmarks

Tags
accelerometer, matrix, position, rotation, translation


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent Live Wallpaper orientation change when an application is opened and orientation is changed? worked Developer 101 1 December 8th, 2010 04:53 PM
Orientation of phone for best GPS reception? KingFatty EVO 4G - Tips and Tricks 2 August 29th, 2010 01:52 PM
Orientation / Accelerometer Problems kingblud Motorola Droid 84 July 13th, 2010 02:40 AM
How do I change the orientation on my phone? psyxologos HTC Desire 1 July 12th, 2010 01:10 AM
Support Motonav, Orientation/Accelerometer problems seanos Motorola Milestone 3 January 18th, 2010 11:22 AM



All times are GMT -5. The time now is 12:56 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo


SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.