I have written a small code to convert the device co-ordinates into
world co-ordinates by multiplying the Rotation matrix(using
getRotationMatrix) and the vector (Ax,Ay,Az) which are the
accelerometer values. When I run this, and the phone is static, I get
a very fluctuating value for the Z axis(from 9.3 to 10.3) and the
other two are 0. However when I give the phone some acceleration in
any direction , it still doesn't show any change to those values and
they remain zero. This is the part of the code where I get the values.

     if(ctp.getType()==Sensor.TYPE_ACCELEROMETER){
            Ca[0]=event.values[0];
            Ca[1]=event.values[1];
            Ca[2]=event.values[2];
            SensorManager.getRotationMatrix(R, I, Ca , Cm);
            for(i=0;i<16;i++)
                rotmat[i/4][i%4]=R[i];
            fAx=0;
            fAy=0;
            fAz=0;
            Ca[3]=0;
            for(i=0;i<4;i++){
                fAx+=rotmat[0][i]*Ca[i];
                fAy+=rotmat[1][i]*Ca[i];
                fAz+=rotmat[2][i]*Ca[i];
            }
            buff1.append(fAx);
            x.setText(buff1.toString());
            buff2.append(fAy);
            y.setText(buff2.toString());
            buff3.append(fAz);
            z.setText(buff3.toString());
        }
        else if(ctp.getType()==Sensor.TYPE_MAGNETIC_FIELD){
            Cm[0]=event.values[0];
            Cm[1]=event.values[1];
            Cm[2]=event.values[2];
        }

Also I would like to know if it would be better to get the rotation
matrix based on the orientation sensor on my own or use the inbuilt
getRotationMatrix?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to