With the right accelerometers and gyros you can actually do this very easily. I've actually done something similar during a basic engineering course (we were detecting earthquakes, but the math is the same).
Edit: Downvote me all you want, but this is not that complicated to calculate.