html5加速度源码,javascript – 用重力将加速度转换为纯加速度?

通过在

Android上使用event.accelerationIncludingGravity,它返回值

x: -0.2

y: +0.1

z: +9.1

在平坦的表面上休息时.但是,我希望在没有重力的情况下获得加速,但不支持event.acceleration.有没有办法通过数学转换它?在HTML5Rocks中有一个删除重力因子的例子,但它似乎不起作用.

// Convert the value from acceleration to degrees acceleration.x|y is the

// acceleration according to gravity, we'll assume we're on Earth and divide

// by 9.81 (earth gravity) to get a percentage value, and then multiply that

// by 90 to convert to degrees.

var tiltLR = Math.round(((acceleration.x) / 9.81) * -90);

var tiltFB = Math.round(((acceleration.y + 9.81) / 9.81) * 90 * facingUp);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值