安卓:从轴方向/旋转角度引导? [英] Android: axes vectors from orientation/rotational angles?

查看:212
本文介绍了安卓:从轴方向/旋转角度引导?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这是在Android的SensorManager一些方法,让你的手机的定位:

 浮法[] =转新的浮动[9];
浮动[] =定位新的浮动[3];
SensorManager.getRotationMatrix(旋转,什么,什么,什么);
SensorManager.getOrientation(旋转,方向);

这为您提供了所谓的旋转旋转矩阵和3个方向角度的数组被称为方向。但是,我不能在我的AR程序中使用的角度 - 我需要的是重新present轴的实际载体

例如,在维基百科这一形象:结果
结果
我基本上报错α,β,γ角(虽然不完全,因为我没有一个N - 我被赋予每个蓝轴的角度),我需要找到它重新载体presents的X,Y和Z轴(在图像中红色)。有谁知道如何做到这一点的转换?维基百科上的方向是非常复杂的,我试图追随他们都没有奏效。另外,我认为,Android为你可能会在一个稍微不同的顺序或格式比在维基百科上的转换方向所需的数据。

或者作为替代这些转换,没有人知道任何其他方式获得的X,Y和从相机的角度Z轴? (意思是,什么矢量相机低头是什么?什么也向量相机认为是涨?)


解决方案

  SensorManager.getRotationMatrix(旋转,空,gravityVals,geoMagVals);//相机的X轴
矢量U =新的向量(-rotational [1],-rotational [4],-rotational [7]); //电话的权利(在横向模式下)
//相机的y轴
向量v =新矢量(旋转[0],旋转[3],旋转[6]); //手机顶部(横向模式)
//摄像机的z轴(负进入场景)
向量n =新矢量(旋转[2],旋转[5],旋转[8]); //手机正面(屏幕)
//世界坐标轴(X,Y,Z):
// + x是东
// + y是北
// + z是天空

So there's a couple methods in the Android SensorManager to get your phone's orientation:

float[] rotational = new float[9];
float[] orientation = new float[3];
SensorManager.getRotationMatrix(rotational, whatever, whatever, whatever);
SensorManager.getOrientation(rotational, orientation);

This gives you a rotation matrix called "rotational" and an array of 3 orientation angles called "orientation". However, I can't use the angles in my AR program - what I need is the actual vectors which represent the axes.

For example, in this image from Wikipedia:

I'm basically being given the α, β, and γ angles (though not exactly since I don't have an N - I'm being given the angles from each of the blue axes), and I need to find vectors which represents the X, Y, and Z axes (red in the image). Does anyone know how to do this conversion? The directions on Wikipedia are very complicated, and my attempts to follow them have not worked. Also, I think the data that Android gives you may be in a slightly different order or format than what the conversion directions on Wikipedia expect.

Or as an alternative to these conversions, does anyone know any other ways to get the X, Y, and Z axes from the camera's perspective? (Meaning, what vector is the camera looking down? And what vector does the camera consider to be "up"?)

解决方案

SensorManager.getRotationMatrix(rotational, null, gravityVals, geoMagVals);

// camera's x-axis
Vector u = new Vector(-rotational[1], -rotational[4], -rotational[7]); // right of phone (in landscape mode)
// camera's y-axis
Vector v = new Vector(rotational[0], rotational[3], rotational[6]); // top of phone (in landscape mode)
// camera's z-axis (negative into the scene)
Vector n = new Vector(rotational[2], rotational[5], rotational[8]); // front of phone (the screen)
// world axes (x,y,z):
// +x is East
// +y is North
// +z is sky

这篇关于安卓:从轴方向/旋转角度引导?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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