开发者

Accelerometer Values from Android/iPhone device

开发者 https://www.devze.com 2022-12-28 02:03 出处:网络
I\'m trying to map my movements with a android device into an OpenGL scene. I\'ve recorded accelerometer values for a simples movement: Moving the phone (lies flat on a table) 10cm forward (+x), and

I'm trying to map my movements with a android device into an OpenGL scene.

I've recorded accelerometer values for a simples movement: Moving the phone (lies flat on a table) 10cm forward (+x), and then 10cm backward (-开发者_如何学Pythonx).

The problem is that this values when used to calculate velocity and position, makes only the opengl cube go forward. Seems like the negative acceleration recorded was not enough to reduce the speed and invert its movement.

What can be the problem?

This is my function that updates the velocity and position every time new data comes in:

void updatePosition(double T2) {
    double T = 0.005;
    Vec3 old_pos = position.clone(), old_vel = velocity.clone();

    velocity = old_vel.plus(acceleration.times(T));
    position = old_pos.plus(old_vel.times(T).plus(acceleration.times(0.5 * Math.pow(T, 2))));

}

This is the X,Y,Z accelerometer values over the entire captured time:

alt text http://img25.imageshack.us/img25/7528/forces.jpg


Your function takes the parameter T2 which I am assuming is the accelerator input? but you are using T which you have declared as double T = 0.005; so your function will be always going forward at a static rate.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号