Android:理解函数remapCooperativeSystem

发布于 2024-10-19 20:11:34 字数 604 浏览 2 评论 0原文

我一直在试图理解我读过的这两行代码

SensorManager.getRotationMatrix(RTmp, I, grav, mag); 
SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X,SensorManager.AXIS_MINUS_Z, Rot);

remapCooperativeSystem() 的文档,但是我迷路了。

谁能向我解释一下 getRotationMatrixremapCooperativeSystem 到底做什么?特别是 SensorManager.AXIS_XSensorManager.AXIS_MINUS_Z

I have been trying to understand these 2 lines of code

SensorManager.getRotationMatrix(RTmp, I, grav, mag); 
SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X,SensorManager.AXIS_MINUS_Z, Rot);

I read the documentation of remapCoordinateSystem(), however I am lost.

Can anyone explain to me what exactly getRotationMatrix and remapCoordinateSystem do? Specially the SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半世晨晓 2024-10-26 20:11:34

我相信 getRotationMatrix() 返回一个旋转矩阵,将设备坐标转换为世界坐标,如 android 文档,而不是“世界”到“设备”。

计算倾斜矩阵 I 以及旋转矩阵 R
将向量从设备坐标系转换为
世界坐标系,定义为直接正交基,其中

I believe getRotationMatrix() returns a rotation matrix that converts device coordinate to world coordinate, as mentioned in android documentation, not "world" to "device".

Computes the inclination matrix I as well as the rotation matrix R
transforming a vector from the device coordinate system to the
world's coordinate system which is defined as a direct orthonormal basis, where

我家小可爱 2024-10-26 20:11:34

我认为 @Noname 已经清楚地解释了 getRotationMatrix() 的功能。我正在尝试回答您的第二个问题和第三个问题,考虑到 remapCooperativeSystem()SensorManager.AXIS_XSensorManager.AXIS_MINUS_Z

remapCooperativeSystem() 所做的实际上是更改坐标系统,设置新的 X、Y、Z 轴,其中 SensorManager.AXIS_X, SensorManager .AXIS_MINUS_Z 是手机的坐标系。从您的代码来看,我相信您正在纵向进行增强现实。这就是您将 Y 轴设置为 SensorManager.AXIS_MINUS_Z 仅供参考的原因。如果您想在横向上做同样的事情,您将按如下方式设置坐标系:

SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, Rot);

我希望这会有所帮助。

I think the function of getRotationMatrix() was clearly explained by @Noname. I am trying to answer your second and third questions considering remapCoordinateSystem() and SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z.

What remapCoordinateSystem() does is actually changing the CoordinateSystem, setting the new X, Y, Z-AXIS where SensorManager.AXIS_X, SensorManager.AXIS_MINUS_Z are the coordinate system of your phone. From your code, I believe you are doing augmented reality in portrait orientation. That's why you set Y-axis to SensorManager.AXIS_MINUS_Z FYI. If you want to do the same thing in landscape orientation, you will set the coordinate system as follow:

SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_Y, SensorManager.AXIS_MINUS_X, Rot);

I hope this helps.

忘羡 2024-10-26 20:11:34

完全断章取义地提出这样的问题通常很难回答。此外,您还应该熟悉格式(例如:4 个空格表示代码):

SensorManager.getRotationMatrix(RTmp, I, grav, mag);
SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X,SensorManager.AXIS_MINUS_Z, Rot);

但是:

我想说您使用文档的方向是正确的。如您所见, getRotationMatrix 拉取将“世界坐标系”转换为当前设备坐标系所需的当前旋转矩阵。
另外,remapcoordinateSystem 将给定的坐标系相应地转换为给定的旋转矩阵。
但如上所述 - 脱离上下文很难告诉你为什么有人这样做。

Asking such a question totally out of context is generally hard to answer. Also you should get familiar with formatting (e.g: 4 spaces indicates code):

SensorManager.getRotationMatrix(RTmp, I, grav, mag);
SensorManager.remapCoordinateSystem(RTmp, SensorManager.AXIS_X,SensorManager.AXIS_MINUS_Z, Rot);

However:

I would say that you are on the right track using the documentation. As you see getRotationMatrix pulls the current rotation matrix needed to transform the "world coordinate system" to the current device coordinate system.
Additionally remapcoordinateSystem transforms the given coordinate System accordingly to the given rotation Matrix.
But as stated above - out of context it is hard to tell you WHY somebody is doing this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文