Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9159113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:24:51+00:00 2026-06-17T13:24:51+00:00

So I am writing a piece of code where I have to detect different

  • 0

So I am writing a piece of code where I have to detect different movement gestures using Accelerometer and gyroscope in iOS 4.3 above.

Q1: Is there any existing opensource code which has achieved any movement/gesture detection?

If not

Q2: For now I want to detect if the iPhone is dropped.

What I have achieved so far:
CoreMotion API gives userAcceleration, which (afaik) is the acceleration that the user is giving to the device or the acceleration of device in some direction (x, y or z) with out considering the gravity so what I can do is: store, let’s say, previous 5-6 values of acceleration parameters and can check where any of them hits large negative value, which basically represents the sudden deceleration.

But this solution is not very optimal, I think I need to somehow detect the freefall/downwards motion of the device too first. Any idea how to approach this problem?

UPDATE:
Thanks Misch for sharing your approach. I was not at all thinking about total acceleration. I did exactly what you said:

“You would however have to test yourself, what means “total acceleration corresponds
approximately to earth acceleration” and “for some time” in your case.”

The acceleration value is actually in G’s so I tested the “total acceleration” values with in range of 0.9 – 1.1. And I checked them over some time, initially I checked four consecutive values when updateInterval is set to 1/20.0. For now I have relaxed the condition of consecutiveness a little.

Here’s a sample output:

Acceleration = 0.090868
Acceleration = 0.074473
Acceleration = 0.159797
Acceleration = 1.157513
Acceleration = 1.224588
Acceleration = 1.036272
Acceleration = 0.914698
Acceleration = 0.904093
Acceleration = 0.941516
Acceleration = 0.046362
Acceleration = 0.045109
Acceleration = 0.060045

I think, I still have to keep on testing and adjusting values. If you have any optimization in mind kindly do share, I know in order to help you’d need to see the many samples of freefall acceleration values. For now I am thinking to:

  1. round off the values of acceleration to 3 decimal places and play with the acceleration range I am using.
  2. May be check if, after the freefall condition is met, total acceleration value suddenly goes down.
  3. Do you think the acceleration values I have quoted are a bit noisy?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T13:24:52+00:00Added an answer on June 17, 2026 at 1:24 pm

    To Q2:

    Checking for large negative values does not tell you whether the phone is being dropped.

    • First, the user could just move the phone with a rapid gesture, this would also result in a large (maybe negative) value.
    • Secondly, the phone could fall in another direction than you imagine, and therefore, the acceleration could be positive, although the phone is moving towards the ground.

    You could just calculate the total acceleration (a = sqrt(ax^2 + ay^2 + az^2)) and check whether this total acceleration corresponds approximately to earth acceleration (9.81). The phone is falling if the acceleration corresponds to earth acceleration for some time.

    You would however have to test yourself, what means “total acceleration corresponds approximately to earth acceleration” and “for some time” in your case.


    The physics behind this:

    Let’s assume you drop your phone in a way, that the y axis of the phone shows upwards. Then the x and z accelerations will be 0 and the y acceleration will be like this:

    Acceleration in y axis

    The acceleration will be 0 in the beginning, will then reach -9.81 the moment, you release your phone. Then it will hit the ground, which you see in the small acceleration peak, and then the acceleration is zero again.

    However you can’t use only the acceleration in y direction, because your phone may fall in a different angle.

    So you have to watch the total acceleration of your phone:

    Total acceleration

    Here you don’t see a negative acceleration anymore. However, here it doesn’t matter anymore in which direction your phone is facing, as a free fall will always be characterized by an acceleration of 9.81.

    To your edits:
    1. Why would you want to round off the values of acceleration to 3 decimal places? If you test 0.9 < x < 1.1, it doesn’t matter if x is 0.914698 or 0.915.
    2. What if someone drops the phone but then catches it again, so the total acceleration does not necessarily have to go down again. Additionally, there should be a large acceleration value (a sudden deceleration) the moment the phone hits the floor. Maybe the reason one does not see this in your values is that it is so short, that it falls between two consecutive measurements. However this could be measured, so don’t suppose that immediately after the free fall, the acceleration should decrease again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem writing a small piece of code using JS/jQuery (don't
I am writing a piece of code in which i have to convert from
I am writing a piece of code in which i have to find only
I have been writing a piece of code for my coursework in electromagnetic simulation
I am trying to have some fun in summer. Writing a piece of code
I am writing a piece of code where I have one class A and
I have started writing a small piece of code to print all the list
I'm writing a little piece of code where I'll have to insert values into
Hello Fellow stackoverflowers, I´m stuck writing a piece of code. I have application with
I am having problems writing a piece of code for android. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.