根据指南针方向计算位移
我需要在编程位移计算时提供一些帮助。鉴于对象已在XY平面和对象的偏航(标题)中移动的距离,我想计算对象的位移。例如,该物体向北5m和2m向东移动。
我拥有的数据是它在xy平面(x距离和y距离)中行驶的距离以及由X方向确定的设备的标题。我知道如何在纸上计算它,但是我很难编程。它。
我附上了两个示例,这些示例显示了我如何获得计算。黑点是对象的位移。在第一个示例中,行进的X距离为3米,而Y距离为4米,X轴的标题为70°。计算后,我设法确定它已向南27330万,东4.187亿。在示例2中,它行驶,X距离为-5m,Y距离为-12m,标题为160°。我计算出该物体向北行驶880m和9.566m。
I need some help with programming the calculation of displacement. Given the distance the object has moved in the XY plane, and the yaw (heading) of the object, I'd like to calculate the displacement of the object. For example, the object moved 5m North and 2m East.
The data I have is the distance it travels in the XY plane (X distance and Y distance) and the heading of the device which is determined by the direction of X. I know how to calculate it on paper but I am having trouble to program it.
I've attached two examples that shows how I obtained the calculations. The black dot is the displacement of the object. In the 1st example, the X-distance travelled is 3 meters while the Y-distance is 4 meters and the heading of the X-axis is 70°. After calculating, I managed to get that it has travelled 2.733m South and 4.187m East. In example 2, it travel, the X-distance is -5m and the Y-distance is -12m, the heading is 160°. I calculated that the object travels 8.80m North and 9.566m East.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设您的XY窗格旋转了一定角度
ZP
,并且在该窗格内有一个2D移动向量,假设其方向由ZV
旋转 - 矢量的总旋转是什么,相对于全球定向?ZP + ZV
...因此,您需要做的就是将旋转
ZP
应用于Xy-Pane内的移动向量,即对向量应用旋转矩阵。此矩阵通过z
旋转的矩阵看起来像:上面的数据:使用
您的第一个示例数据给出:对
您计算的值几乎相对应走向南...)。
Assume you have your XY pane rotated by some angle
Zp
and have a 2D movement vector within that pane, let's say its direction rotated byZv
– what is total rotation of the vector, relative to the global orientation?Zp + Zv
...So all you need to do is applying the rotation
Zp
to the movement vector within XY-pane, i. e. apply a rotation matrix to the vector. This matrix for a rotation byz
looks like:With our data above:
which gives, with your first sample data applied:
Corresponding pretty much to the values you calculated (note: negative movement to north is positive movement towards south...).
您正在做的是从极地到笛卡尔坐标的转换。 nofollow noreferrer“>坐标
如果您的笛卡尔坐标不与极轴对齐,只需通过将旋转角度添加到极性参数来补偿。
What you are doing is a conversion from polar to Cartesian coordinates. https://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordinates
If your Cartesian coordinates are not aligned to the polar axis, just compensate by adding the rotation angle to the polar argument.