objective-cuiaccelerometerdifferentiation

Find 2nd Derivative of Acceleration - UIAccelerate


Hi I'm working on an iOS app that requires finding the z value of the accelerometer and then deriving it twice of find the "Jounce" value. Heres what I have so far:

In

-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration

I get the "z" value of acceleration and assign it to a variable:

float currentAccc = acceleration.z;

After this I don't know how to differentiate twice. How do I differentiate in Obj-C?

Thanks


Solution

  • You'll want to know something about finite differences in order to do this.

    A single discrete value is insufficient.

    A first order derivative w.r.t. time would look like this:

    da/dt(t) ~ (a(t+dt)-a(t))/dt
    d^2a/dt^2(t) ~ (da/dt(t+dt)-da/dt(t))/dt
    

    (I could make this easier to read if I had LaTeX.)

    You can use other formulas, but these are simplest.

    The ideas are commonly understood from differential calculus.