- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我必须在 Android 中从陀螺仪的智能手机输出中计算偏航、滚转、俯仰,我编写了以下代码:
if(event.sensor.getType()==Sensor.TYPE_GYROSCOPE){
float xgyr=event.values[0]; //rotation around x-axis [rad/sec]
float ygyr=event.values[1]; // rotation around y-axis
float zgyr=event.values[2]; // rotation around z-axis
// This timestep's delta rotation to be multiplied by the current rotation
// after computing it from the gyro sample data.
double EPSILON = 0.0; //EPSILON value to be defined
if (timestamp != 0) {
final float dT = (event.timestamp - timestamp) * NS2S;
// Axis of the rotation sample, not normalized yet.
float axisX = event.values[0];
float axisY = event.values[1];
float axisZ = event.values[2];
// Calculate the angular speed of the sample, teta is the vector length
float omegaMagnitude = (float) Math.sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ);
// Normalize the rotation vector if it's big enough to get the axis
if (omegaMagnitude > EPSILON) { //EPSILON TO BE DEFINED
axisX /= omegaMagnitude;
axisY /= omegaMagnitude;
axisZ /= omegaMagnitude;
}
float thetaOverTwo = omegaMagnitude * dT / 2.0f; //Insert initial value for orientation omegaMagnitude
float sinThetaOverTwo = (float) Math.sin(thetaOverTwo);
float cosThetaOverTwo = (float) Math.cos(thetaOverTwo);
/*rotation vector, a non-normalized three-dimensional vector the direction of which specifies the rotation axis,
and the length of which is teta, Combining two consecutive quaternion rotations is therefore just as simple as using the rotation matrix.
Remember that two successive rotation matrices, A1 , A2 are combined A3 = A2*A1*/
//Quaternions
deltaRotationVector[0] = sinThetaOverTwo * axisX;
deltaRotationVector[1] = sinThetaOverTwo * axisY;
deltaRotationVector[2] = sinThetaOverTwo * axisZ;
deltaRotationVector[3] = cosThetaOverTwo;
}
timestamp = event.timestamp;
float[] deltaRotationMatrix = new float[9];
SensorManager.getRotationMatrixFromVector(deltaRotationMatrix, deltaRotationVector);
// User code should concatenate the delta rotation we computed with the current rotation
// in order to get the updated rotation.
// rotationCurrent = rotationCurrent * deltaRotationMatrix; The initial rotation has to be computedand then at each step updated
/*Rotation current is a vector with rotation on pitch, roll, yaw (3x1) multiplied by 3x3 rotation matrix i have the new orientation*/
/*In the "xyz (pitch-roll-yaw) convention," theta is pitch, psi is roll, and phi is yaw. */
double pitch = Math.atan2(deltaRotationMatrix[6], deltaRotationMatrix[7]);
double roll = Math.acos(deltaRotationMatrix[8]);
double yaw = - Math.atan2(deltaRotationMatrix[2], deltaRotationMatrix[5]);
最佳答案
我在 Android 上的经验有限,但根据引用手册,您可以从 SensorManager.getOrientation (...) 获得这些值。无需任何计算。如果这是正确的,我建议使用它而不是任何自制的计算,因为由于在引擎盖下工作的传感器融合算法,这些值应该更精确。
关于orientation - 如何从旋转矩阵计算偏航、俯仰?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12933962/
我必须在 Android 中从陀螺仪的智能手机输出中计算偏航、滚转、俯仰,我编写了以下代码: if(event.sensor.getType()==Sensor.TYPE_GYROSCOPE){
四元数有利于它们之间的内插旋转。到目前为止,一切都很好。 如果我有一个网络游戏,将旋转量转换为vector3f就足够了还是应该使用四元数? 为了使游戏更流畅,我可能必须在上次发送的旋转和当前旋转之间进
我正在使用Reach RS +设备来捕获GPS位置数据以及IMU数据(侧倾,俯仰和偏航);请参阅制造商website上的“ Point Collection”图像。 我正在尝试确定底点的GPS坐标(接
如果可能的话,我想知道如何获得确定 Android 设备位置的航向、俯仰和滚动角度。不要考虑设备相关的细节。引用有用的文档也很有值(value)。谢谢! 最佳答案 我手头没有精确的解决方案,但全口径解
我在 WorldWind 中有一个 3D 飞机模型,这是一个在 OpenGL Java 上运行的 3D 地球模型。我使用数据库中的数据(包括纬度、经度和替代度)更新此模型的位置。如何从当前位置获取航向
我想在没有红外感应条的情况下使用 wiimote 来控制光标。我为此使用了俯仰和滚动值。问题是俯仰接近0度的时候,横滚很不稳定,而俯仰接近90度的时候,本身就很不稳定,但是横滚还好。我非常频繁地轮询
我正在为我的学校做一个编程主题的项目。我在 Swift 的 Xcode 中工作。我想制作一个使用陀螺仪的应用程序。我不知道,但由于 Xcode 中的一些我不知道如何修复的错误,它不会在我的 iPhon
我正在尝试使用 Vision 框架获取图像中人脸的俯仰/偏航/滚动,但始终为所有值获取 0。图像应该很容易处理(主要是前瞻性肖像)。 我通过对它们使用 Amazon Rekognition 成功获得了
我有一个基于提供的纬度/经度坐标、缩放、偏航和俯仰的谷歌地图和街景。我需要调用一个 javascript 来为每个值更新一个隐藏字段,每当任何细节从它们的默认值发生变化或当一个按钮被点击时。 因此,无
我的观众没有收到来自被跟随球员的任何投球轮换。 我正尝试与 ShooterGame 项目合作,对 FPS 旁观者功能进行概念验证。我在 GameMode 中添加了将 VictimPlayer 切换到旁
我正在尝试使用陀螺仪制作一个简单的应用程序,其中角色会根据 iPad 1 的旋转进行移动。 我的代码无法正常工作,因此我测试了原始、俯仰、偏航的值,无论我如何移动设备,它们实际上都保持为零。我确定 i
用于从 cvPOSIT 生成的 3*3 旋转矩阵计算偏航(z 轴)、横滚(x 轴)和俯仰(y 轴)的算法是什么。 最佳答案 使用cv::RQDecomp3x3() .“它可选择返回三个旋转矩阵,每个轴
我已经研究了一段时间,现在我必须决定走哪条路。 矿山要求:需要知道设备相对于真实航向(地理北极,而非磁极)的方向。为此,我必须使用指南针,现在我必须决定其他的东西,加速度计或陀螺仪。 因为这对我来说是
我的问题 我想用 3x3 旋转矩阵旋转一个 mayavi.mlab.imshow 对象。我能找到的唯一旋转此对象的方法是将对象的 actor.orientation 设置为 [pitch, roll,
我是一名优秀的程序员,十分优秀!