如何同步四元数中具有相同方向的两点的位置? [英] How to synchronize the position of two points with the same orientation represented in quaternion?

查看:55
本文介绍了如何同步四元数中具有相同方向的两点的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 3D 空间中有两个具有固定距离(例如 30 厘米)且方向完全相同的点.点 1 (x1,y1,z1) 的位置和点 1 的方向(用四元数 q0、q1、q2、q3 表示)是已知的.如何计算点 2 的位置?(无论我如何移动它们,它们之间的距离都不会改变,方向始终相同)

我在网上搜索,这是我能找到的最接近的问题 但是它有点不同.

假设你的两个粒子位置是 p1 和 p2,第一个粒子的旋转是 q1 = [w1, x1, y1, z1].P1和P2之间的相对四元数方向为q12,相对位置为p12 = p2 - p1.然后:

p2 = p1 + C(q1)*p12q2 = q1 ⊗ q12

其中 ⊗ 是四元数乘法运算符,C(q1) 是由 q1 形成的旋转矩阵.请参阅我上面发布的链接,了解如何在没有 C(q) 函数的情况下执行此操作.

对于 funsies,任何在 P2 之间进行刚性变换的粒子 P3 的位置和方向都非常相似:

p3 = p2 + C(q2)*p23q3 = q2 ⊗ q23

我添加了一个图形和动画来尝试解释相对位置和方向,尽管这很难做到,所以我只展示了只有 (x, y) 和旋转的 2D 情况z 轴.相同的概念适用于 3d,但更难可视化.

你必须知道P1和P2在父框架中表达的相对位置,以及相对方向.或者你可以通过知道每个粒子在全局坐标系中的初始位置和方向来解决这些问题,但这对于四元数来说更加困难.相对位置相当简单,但方向需要一些努力.首先找到使 P1 轴与 P2 轴对齐的欧拉角旋转序列.然后使用一些库来转换 Euler->quaternion.

I have two points with fixed distance (e.g. 30 centimeter) and exactly the same orientation in 3D space. The position of point 1 (x1,y1,z1) and orientation of point 1 (represented in quaternion q0, q1, q2, q3) are already known. How can I calculate the position of point 2 ? (No matter how I move them, the distance between them won't change and the orientation will always be the same)

I searched on the web, and this is the closest question I can find https://www.opengl.org/discussion_boards/showthread.php/173480-Calculate-object-orientation-from-a-quaternion but I still could not figure out how to solve it. I guess I didn't define the problem correctly so that I'm not able to find the right mathmatical solution. Thanks!

解决方案

From what I understood of your question you have two particles P1 and P2 that have a rigid transformation between them (at all times the relative position and relative orientation between P1 and P2 are constant).

The answer is similar to this answer however it is a bit different.

Lets say your two particle positions are p1 and p2, and the rotation of the first particle is q1 = [w1, x1, y1, z1]. The relative quaternion orientation between P1 and P2 is q12 and the relative position is p12 = p2 - p1. Then:

p2 = p1 + C(q1)*p12
q2 = q1 ⊗ q12

Where ⊗ is the quaternion multiplication operator, and C(q1) is the rotation matrix formed from q1. See the link I posted above for how to do this without the C(q) function.

For funsies, the position and orientation of any particle P3 with a rigid transform between P2 is very similar:

p3 = p2 + C(q2)*p23
q3 = q2 ⊗ q23

EDIT: I've added a figure and animation to try and explain the relative position and orientations, although it is hard to do, so I have shown only the 2D case which has only (x, y) and rotation about the z axis. The same concept applies to 3d but it is harder to visualise.

You must know the relative position between P1 and P2 expressed in the parent frame, as well as the relative orientation. Or you can work those out by knowing the initial positions and orientations of each particle in the Global frame, but this is more difficult with quaternions. The relative positions are fairly straightforward, but the orientations require a bit of effort. First find the Euler angle rotation sequence that brings P1 axes into alignment with the P2 axes. Then use some library to convert the Euler->quaternion.

这篇关于如何同步四元数中具有相同方向的两点的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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