Hardly any theory, and I can't see what you'd analyze with MATLAB. The first thing to realize is that the assumption is that you're not accelerating at the same time. Things get more complex if you include acceleration.
Given that assumption, then the three acceleration sensors give you the X, Y, and Z direction of gravity in device coordinates. The magnetic sensors likewise give you the direction of magnetic north, unless you're over the magnetic poles, in which case, the magnetic field and gravity are aligned, and the cross-product will be zero. Except for that case, the magnetic sensors give you your your orientation around the vertical axis (in world coordinates) I don't see how we can explain it to you in text. You really need pictures and diagrams. Especially since the comments in the code already tell you what it's doing. I'd suggest a basic textbook on 3D computer graphics that talks about rotation matrices and linear (vector) algebra, or perhaps a course in linear algebra. Preferably both! There's a great course in Linear Algebra on MIT's open courseware site taught by Gilbert Strang; the first part of that should get you oriented as to what a matrix really is and means; combine that with the more application-specific approach that'll be taken by any computer graphics text discussing affine transformations (rotation is one type of affine transformations, and affine transformations are the ones used in computer graphics and represented by matrices). The basic math things you need to know are: 1) What a matrix is. 2) What a vector is. 3) Vector cross product (vector product) 4) Vector dot product (scalar product) 5) The magnitude of a vector (Pythagorean theorem) 6) The use of a matrix to represent rotation. (Multiplying a vector by a rotation matrix gives you a new vector, rotated by that amount). For getOrientation(), you also need basic trigonometry, as well as understanding how Math.atan2 is used rather than Math.atan (to avoid ambiguity as to which quadrant you're in). I would guess that you probably already have these individual skills. I suspect your problem is just that you expect to need MORE than this list, and you're a bit lost about how to apply and combine them or where in the code they're being applied. If you haven't done this sort of thing before, it can be a bit intimidating. I'd even have to stop and think it through carefully to write this code, because it's not something I do regularly. That's why we have matrices -- so we don't have to think about the individual formulae that each matrix represents. On Mar 27, 10:30 pm, DD <[email protected]> wrote: > Hi, > > I know Android calculates the orientation of the phone by fusing the > acceleration and magnetic field readings. The related APIs are > getRotationMatrix() and getOrientation(). I looked into the source > code of these two > APIshttp://www.netmite.com/android/mydroid/cupcake/frameworks/base/core/j... > > But I couldn't really figure out where exactly the implementation came > from... Could anybody tell me where I can find the theory of this > algorithm and detailed mathematical background of it? I'm currently > implementing exactly the same algorithm offline in MATLAB, and trying > to write some mathematical analysis about it. > > Thank you very much! -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

