磁场、旋转矩阵和全局坐标 [英] Magnetic Fields, Rotation Matrix And global coordinates

查看:35
本文介绍了磁场、旋转矩阵和全局坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我已经阅读了关于这个主题的所有帖子,但我仍然无法理解一些事情:

I think that i've read all the posts about this subject, but still i cant understand a few things:

第一季度:为了得到全局坐标中的磁场矢量,我需要将旋转矩阵逆矩阵和磁场矢量相乘,为什么我需要旋转矩阵逆矩阵?

Q1: To get the magnetic field vector in global coords i need to multiply the inverted rotation matrix and the magnetic field vector, why do i need to invert the rotation matrix?

第 2 季度:假设我有一个设备,我可以使用 getOrientation(...) 方法根据沿 Z 轴的旋转计算方位角.无论手机的姿态如何,我都可以使用旋转矩阵或其他方法来计算磁北的方位角吗?所以如果我旋转手机,我和磁北之间的角度会保持不变吗?

Q2: Lets say that i have a device and i can calculate the azimuth based on the rotation along the Z-axis using getOrientation(...) method. can i use the rotation matrix or some other method to calculate the azimuth to magnetic north regardless to the phone attitude? So if i will rotate the phone the angle between me and the magnetic north will remain the same?

Q3:当我将磁矢量(第 4 列为零)与反向旋转矩阵相乘时,我得到 x 非常接近于零.我从其他帖子知道这没问题,但我不明白为什么?

Q3: When i multiply the magnetic vector(4th col is zero) with the inverted rotation matrix i get that x is very close to zero. i know that this is o.k from other posts but i cant understand why?

第 4 季度:理论上,假设我有两个相距 1 米的设备,是否可以仅根据它们的磁场(全局坐标)确定这两个设备的空间位置

Q4: In theory, lets say that i have two devices located 1 meter from each other, is it possible to make a spatial position of the two devices based only on their magnetic fields (in global coords)

提前致谢.

附言我已经阅读了这些帖子:获取全局磁场值坐标,如何获得磁性场矢量,与设备旋转无关?

P.S I've already read these posts: Getting magnetic field values in global coordinates, How can I get the magnetic field vector, independent of the device rotation?

转换磁场 X、Y、从设备到全局参考系的 Z 值

推荐答案

如果你在 将设备的磁场 X、Y、Z 值转换为全局参考系 你还是不明白.

If you read my answer at Convert magnetic field X, Y, Z values from device into global reference frame You still do not understand it.

A1.您将旋转矩阵与设备坐标系中磁场矢量的坐标相乘,得到磁场矢量在世界上的坐标坐标系.

A1. You multiply the Rotation matrix with the coordinates of the magnetic field vector in device coordinate system to get the coordinates of the magnetic field vector in the world coordinate system.

强调一下:上面说的是旋转矩阵而不是逆旋转矩阵.

调用getRotationMatrix得到的旋转矩阵是基矩阵从设备基到世界基的变化.即给定任意向量v在设备坐标系中的坐标,同一个向量v在世界坐标系中的坐标可以通过乘以旋转矩阵 与设备系统坐标中的坐标.

The Rotation matrix obtained by calling getRotationMatrix is the change of basis matrix from the device basis to the world basis. That is given any vector v with coordinates in device coordinate sytem, the coordinates in world coordinate system of the same vector v can be obtained by multiply the rotation matrix with the coordinates in device system coordinate.

逆旋转矩阵是基矩阵从世界基到设备基的变化.因此,当您将此矩阵与坐标相乘时,它被解释为将矩阵与世界坐标系中的向量坐标相乘以获得设备坐标系中相同向量的坐标.因此,如果您将逆旋转矩阵磁传感器返回的磁场矢量的坐标相乘.然后坐标被解释为世界坐标系中向量的坐标,因此代表磁场向量,结果乘积不是<世界坐标系中的强>磁场矢量.实际上它是设备坐标系中向量的坐标.

The inverted rotation matrix is the change of basis matrix from the world basis to the device basis. Thus when you multitply this matrix with a coordinates, it is interpreted as multiply the matrix with the coordinates of a vector in world coordinate system to obtain the coordinates of the same vector in device coordinate system. Therefore if you multiply the inverted rotation matrix with the coordinates of the magnetic field vector as returned by the magnetic sensor. Then the coordinates is interpreted as the coordinates of a vector in the world coordinate system and thus do not represent the magnetic field vector and the resulting product is not the coordinates of the magnetic field vector in the world coordinates system. Actually it is the coordinates of a vector in device coordinate system.

A2. getOrientation 仅在设备平坦时才有意义.对我来说,这只是一堆角度计算.我查看我尝试几何做的事情,然后使用旋转矩阵来计算我想要的.比如计算后置摄像头指向的方向,我把它看成-z的方向(与屏幕正交的向量的反方向).因此,为了找到这个方向,我将 -z 投影到世界 东西北平面 并计算此 投影向量 之间的角度>北轴.现在,如果您这样想,那么设备的旋转将不会改变 -z 的方向,因此 投影向量 与您旋转设备时相同.如果你使用 getOrientation 那么你必须预先调用 remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR)getOrientation 给你正确的结果.

A2. getOrientation is meaningful only if the device is flat. For me it just a bunch of angle calculations. I look at what I try to do geometrically and then use the rotation matrix to calculate what I want. For example, to calculate the direction where the back camera pointed, I look at it as the direction of -z (the opposite of the vector orthogonal to the screen). Thus to find this direction, I projected -z to the world East-North plane and calculate the angle between this projection vector and the North axis. Now if you think this way then rotation of the device will not change the direction of -z, thus the projection vectors are the same as you rotate the device. If you use getOrientation then you have to precall remapCoordinateSystem(inR, AXIS_X, AXIS_Z, outR) for getOrientation to give you the correct result.

A3. getRotationMatrix 假设 地磁参数 是完全位于 North-Sky 平面中的矢量的坐标.好吧,位于该平面上的任何向量都必须具有 x 坐标等于 0.这只是基本的线性代数.

A3. The getRotationMatrix assumes that the geomagnetic parameter is the coordinates of a vector lying entirely in the North-Sky plane. Well any vector lying in this plane has to have x coordinate equal to 0. This is just basic linear algebra.

A4.答案是否定的.要获得空间位置,您必须相对于固定坐标系来表达这些向量.只有这些向量在设备坐标系中的坐标,你无法找到一个固定基来计算基矩阵从设备基到这个固定基础.需要满足我上面链接中提到的 2 个条件才能计算基差.

A4. The answer is no. To get the spatial position you have to be to express these vectors relative to a fixed coordinate system. with only coordinates of these vectors in device coordinate system, there is no way you can find a fixed basis that allow you to calculate the change of basis matrix from the device basis to this fixed basis. The 2 conditions stated in my link above need to be satisfied to calculate the change of basis.

这篇关于磁场、旋转矩阵和全局坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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