使用Android的加速度计,而无需设备平 [英] Using the Android Accelerometer without having the device flat

查看:138
本文介绍了使用Android的加速度计,而无需设备平的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Android SDK和Adobe AIR的Andr​​oid SDK中对我的摩托罗拉Droid玩弄后期的Andr​​oid的加速度。我所注意到的是,加速度计工作得很好,但我想知道是否有可能以某种方式来补偿,这样我就不必使用该设备在水平位置。换句话说,我想用加速感应器来控制我的直观显示,但对其进行初始化(或修改以某种方式),这样我就不必持有它完全平坦的(没有多少乐趣不得不俯身电话)。

I've been playing around with the Android Accelerometer of late using the Android SDK and the Adobe AIR for Android SDK on my Motorola Droid. What I've noticed is that the accelerometer works just fine, but I was wondering if it is possible to compensate in some fashion so that I don't have to use the device in a horizontal position. In other words, I want to use the accelerometer to control my visual display, but initialize it(or modify in some way) so that I don't have to hold it perfectly flat (not much fun having to lean over the phone).

有谁知道我可以把设备舒适在我手里,说45度,而且还利用加速计提供前进/后退的读数?这可能吗?这个例子任何这可用?

Does anyone know how I can hold the device comfortably in my hand, say 45 degrees, and still utilize the accelerometer to provide forward/backwards readings? Is this possible? Any examples of this this available?

推荐答案

您将需要一些简单的矩阵乘法运算为。当你启动应用程序校准旋转采取当前矩阵并倒转,再乘以所有后续的矩阵与它 - 这将使你的三角形的起始位置

You'll need some simple matrix multiplication math for that. "Calibrate" the rotation by taking the current matrix when you start the app and invert it, then multiply all subsequent matrices with it - that will give you the delta to the starting position.

这篇关于使用Android的加速度计,而无需设备平的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆