Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
LinkBack Thread Tools
Old March 6th, 2010, 01:54 PM   #1 (permalink)
New Member
Thread Author (OP)
Join Date: Mar 2010
Posts: 1
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Accelerometer results translation from phone to word orientation

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];
The mR and mI are defined as:
private float[] mR = new float[9];
private float[] mI = new float[9];
Please advice

ofer is offline  
Reply With Quote
sponsored links
accelerometer, matrix, position, rotation, translation

Go Back   Android Forums > Android Development > Application Development
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

All times are GMT -5. The time now is 11:12 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.