How to combine accelerometer values into 1


Last Updated:

  1. rcasha

    rcasha New Member This Topic's Starter

    Joined:
    Nov 15, 2009
    Messages:
    2
    Likes Received:
    0
    I'm developing an application which measures the accelerometer values to indicate how much the phone is being shaken. At the moment I'm just using the Z value, which works if the phone is lying flat on its back.
    Is there any formula to combine x + y + z in order to give the value irrespective of the orientation of the phone?
     

    Advertisement
  2. metter

    metter Active Member

    Joined:
    Oct 19, 2009
    Messages:
    33
    Likes Received:
    0
    If you mean what I think you mean:

    If only Z it's Z.
    X+Z it's: VALxz^2=X^2+Z^2
    X+Y+Z it's: VALxyz^2 = VALxz^2 + Y^2



    Hope that helps. Cheers.
     
  3. DaveInNYC

    DaveInNYC Well-Known Member

    Joined:
    Nov 7, 2009
    Messages:
    52
    Likes Received:
    3
    My answer is somewhat close to what Metter said, but if I understand your question correctly, you want to get the amount of acceleration irrespective of direction. If that is the case, the value you would be looking for is the root of the sum of the squares:

    absolute value = sqrt(X^2 + Y^2 + Z^2);

    See The Pythagorean Theorem for details.
     
  4. rcasha

    rcasha New Member This Topic's Starter

    Joined:
    Nov 15, 2009
    Messages:
    2
    Likes Received:
    0
    What I mean is: "How much is the phone being shaken - whether up and down, or sideways, or diagonally, etc?"

    DaveInNYC: Thanks, that's what I needed.
     
  5. metter

    metter Active Member

    Joined:
    Oct 19, 2009
    Messages:
    33
    Likes Received:
    0
    And that's exactly what I wrote. I just left you some thinking ;)
     

Share This Page

Loading...