Hi Mike

I am not sure what you are asking. The code combines magnetic and
acceleration information to obtain the phone orientation.

Are you trying to determine if the phone is being accelerated toward
the North pole, for example? I don't think there are routines for
doing that. (Except by using GPS but I assume that is not what you
want.)

Rud
http://mysticlakesoftware.blogspot.com/


On Aug 24, 5:07 pm, Mike Collins <mike.d.coll...@gmail.com> wrote:
> I must be dense but can't seem to make the documentation around this
> make
> sense.  I can compute the phone orientation in earth-relative
> coordinates but
> can't figure out how to get the phone-relative acceleration values
> expressed
> in the earth coordinate system.
>
> I tried multiplying the rotation matrix by the acceleration vector and
> also remapped
> rotation matrix...
>
> Any thoughts?
>
> On Aug 21, 11:07 am, Mike Collins <mike.d.coll...@gmail.com> wrote:
>
>
>
> > Thanks, that seems to work, the orientation is now relative to the
> > earth.  The documentation could use a little work...
>
> >   mike
>
> > On Aug 20, 7:08 pm, mscwd01 <mscw...@gmail.com> wrote:
>
> > > Oh and you'll need these:
>
> > > final int matrix_size = 16;
> > > float[] R = new float[matrix_size];
> > > float[] outR = new float[matrix_size];
> > > float[] I = new float[matrix_size];
> > > float[] values = new float[3];
>
> > > On Aug 21, 3:06 am, mscwd01 <mscw...@gmail.com> wrote:
>
> > > > Heres my code, which works:
>
> > > > public void onSensorChanged(SensorEvent event) {
>
> > > >         Sensor sensor = event.sensor;
> > > >         int type = sensor.getType();
> > > >         switch (type) {
> > > >                 case Sensor.TYPE_MAGNETIC_FIELD:
> > > >                         mags = event.values.clone();
> > > >                         isReady = true;
> > > >                     break;
> > > >                 case Sensor.TYPE_ACCELEROMETER:
> > > >                     accels = event.values.clone();
> > > >                     break;
> > > >                 case Sensor.TYPE_ORIENTATION:
> > > >                     orients = event.values.clone();
> > > >                     break;
> > > >             }
>
> > > >             if (mags != null && accels != null && isReady) {
> > > >                 isReady = false;
>
> > > >                     SensorManager.getRotationMatrix(R, I, accels, mags);
> > > >                     SensorManager.remapCoordinateSystem(R,
> > > > SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, outR);
> > > >                     SensorManager.getOrientation(outR, values);
>
> > > >                                 azimuth = 
> > > > getAzimuth(-convert.radToDeg(values[0]));
> > > >                                 pitch= convert.radToDeg(values[1]);
> > > >                                 roll = -convert.radToDeg(values[2]);
>
> > > >             }
>
> > > >         }
>
> > > > On Aug 21, 2:39 am, Mike Collins <mike.d.coll...@gmail.com> wrote:
>
> > > > > I have a sensor event handler that gets fired and I have no problem
> > > > > getting and processing acceleration readings. However this code
> > > > > always fails.
>
> > > > >                 if (event.sensor.getType() == 
> > > > > Sensor.TYPE_ACCELEROMETER)
> > > > >                 {
> > > > >                         float[] geomagnetic = new float[3];
> > > > >                         geomagnetic[0] = geomagnetic[1] = 
> > > > > geomagnetic[2] = 0;
>
> > > > >                         float[] r = new float[9];
> > > > >                         float[] I = new float[9];
> > > > >                         boolean b = 
> > > > > SensorManager.getRotationMatrix(r, I, event.values.clone
> > > > > (), event.values.clone());
> > > > >                         if ( ! b)
> > > > >                         {
> > > > >                                 Log.e(LOG_TAG, "getRotationMatrix 
> > > > > failed");
> > > > >                                 return;
> > > > >                         }
> > > > > ...
>
> > > > > tia,
> > > > >   mike- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to