将单位向量转换为四元数 [英] Convert a Unit Vector to a Quaternion

查看:460
本文介绍了将单位向量转换为四元数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我对四元数非常陌生,但是我了解如何使用四元数来处理事物.我目前正在尝试做的是将已知的四元数与空间中的两个绝对点进行比较.我希望我能做的只是将这些点转换为第二个四元数,从而为我提供了一种比较两者的简便方法.

到目前为止,我所做的是将两个点转换为单位向量.从那时起,我希望我可以直接将i j k插入标量为零的四元数的虚部.从那里,我可以将一个四元数与另一个的共轭相乘,得到第三个四元数.可以将第三个四元数转换为轴角,从而获得原始两个四元数相差的程度.

这个思考过程正确吗?因此它应该只是[0 i j k].之后,我可能需要对四元数进行归一化,但是我不确定.

我很难过,它不是从向量到四元数的直接映射.我尝试着将单位矢量转换为轴角,但是我不确定这样做是否可行,因为我不知道输入哪个角度即可.

解决方案

符号

四元数在以{1,i,j,k}为底的四空间中定义.汉密尔顿(Hamilton)在都柏林布劳姆大桥(Brougham Bridge)的石头上雕刻了基本的关系:

i 2 = j 2 = k 2 = i j k = -1.

有许多等效的四元数参数化,但是这里我将使用{标量, vector }形式.

1.)A = {a0, a }和B = {b0, b },其中A和B是四元数,a0和b0是标量,并且 a b 是三个向量.

2.)X = {0, x }是向量四元数.

3.)(非可交换的)四元数乘积直接来自上面i,j和k的属性,A&otimesB = {a0 b0- a . b ,a0 b + b0 a + a x b }

4.)四元数共轭是A * = {a0,- a }

5.)四元数产物的缀合物是相反顺序的缀合物的产物.
(A⊗ B) * = B * ⊗ A *

6.)向量四元数的共轭是负数. X * = {0,- x } = -X

7.)四元数范数为| A |. =√(A⊗ A * )=√(a0² + a . a )

8.)一个单元四元数是范数为1的单元.

9.)单位三向量 x = {x 1 ,x 2 ,x 3 }和 x . x = 1可表示为单位矢量四元数 X = {0, x },| X | = 1.

10.)四元数矢量X的球面旋转,角度为θ.关于单位矢量轴 n 的值是Q⊗ X⊗ Q * , 其中Q是四元数{cos(θ/2),sin(θ/2) n }.注意| Q | = 1.

注意四元数向量乘积的形式.给定向量四元数X 1 = {0, x 1 )和X 2 = {0, x 2 },四元数乘积为X 2 ⊗ X 1 * = { x 1 . x 2 x 1 和时间; x 2 }.四元数离婚了一百多年前,将点积重新组合为标量部分,将叉积重新组合为矢量部分.这些产品都不是可逆的,但是四元数的描述如下.

反转

找到球面变换四元数Q 12 以旋转向量X 1 以与向量X 2 对齐.

从上方

X 2 = Q 12 ⊗ X 1 ⊗ Q 12 *

将两边都乘以X 1 *

X 2 ⊗ X 1 * = Q 12 ⊗ X 1 ⊗(Q 12 * ⊗ X 1 * )

请记住,旋转轴 n 来自叉积 x 1 × x 2 ,因此 n . x 1 =0.并且Q * ⊗ X * =(X⊗ Q) * = X * ⊗ Q,离开

X 2 ⊗ X 1 * = Q 12 ⊗ X 1 ⊗ X 1 * ⊗ Q 12 = Q 12 ⊗ Q 12

因此四元数变换可以直接求解为

Q 12 =√(X 2 ⊗ X 1 * )

您自己依靠四元数平方根.有很多方法可以做到,最好的方法取决于您的应用程序,同时考虑速度和稳定性.

-hth,
弗雷德·克林格纳(Fred Klingener)

So I'm very new to quaternions, but I understand the basics of how to manipulate stuff with them. What I'm currently trying to do is compare a known quaternion to two absolute points in space. I'm hoping what I can do is simply convert the points into a second quaternion, giving me an easy way to compare the two.

What I've done so far is to turn the two points into a unit vector. From there I was hoping I could directly plug in the i j k into the imaginary portion of the quaternion with a scalar of zero. From there I could multiply one quaternion by the other's conjugate, resulting in a third quaternion. This third quaternion could be converted into an axis angle, giving me the degree by which the original two quaternions differ by.

Is this thought process correct? So it should just be [ 0 i j k ]. I may need to normalize the quaternion afterwards, but I'm not sure about that.

I have a bad feeling that it's not a direct mapping from a vector to a quaternion. I tried looking at converting the unit vector to an axis angle, but I'm not sure this would work, since I don't know what angle to give as an input.

解决方案

Notation

Quaternions are defined in a four-space with bases {1, i, j, k}. Hamilton famously carved the fundamental relationship into the stone of the Brougham Bridge in Dublin:

i2 = j2 = k2 = i j k = -1.

There are many equivalent quaternion parameterizations, but here I'll use a {scalar, vector} form.

1.) A = {a0, a} and B = {b0, b}, where A and B are quaternions, a0 and b0 are scalars, and a and b are three-vectors.

2.) X = { 0, x } is a vector quaternion.

3.) The (non-commutative) quaternion product derives directly from the properties of i, j and k above, A⊗B = {a0 b0 - a.b, a0 b + b0 a + a x b}

4.) The quaternion conjugate is A* = {a0, - a}

5.) The conjugate of a quaternion product is the product of the conjugates in reverse order.
(A⊗B)* = B*⊗A*

6.) The conjugate of a vector quaternion is its negative. X* = {0, -x } = -X

7.) The quaternion norm is |A| = √(A⊗A*) = √( a0² + a.a )

8.) A unit quaternion is one that has a norm of 1.

9.) A unit three-vector x = {x1, x2, x3} with x . x = 1 is expressible as a unit vector quaternion X = { 0, x }, |X| = 1.

10.) The spherical rotation of a quaternion vector X by an angle θ about a unit vector axis n is Q⊗X⊗Q*, where Q is the quaternion {cos(θ/2), sin(θ/2) n }. Note that |Q| = 1.

Notice the form of the quaternion vector product. Given vector quaternions X1 = { 0, x1 ) and X2 = { 0, x2 }, the quaternion product is X2⊗X1* = { x1.x2, x1 × x2 }. The quaternion reunites the dot product as the scalar part and cross product as the vector part, divorced over a hundred years ago. Neither of these products is invertible, but the quaternion is in the way described below.

Inversion

Find the spherical transform quaternion Q12 to rotate vector X1 to align with vector X2.

From above

X2 = Q12⊗X1⊗Q12*

Multiplying both sides by X1*,

X2⊗X1* = Q12⊗X1⊗(Q12*⊗X1*)

Remember that the rotation axis n derives from the cross product x1×x2, so n . x1 = 0. and Q*⊗X* = (X⊗Q)* = X*⊗Q, leaving

X2⊗X1* = Q12⊗X1⊗X1*⊗Q12 = Q12⊗Q12

So the quaternion transform can be solved directly as

Q12 = √(X2⊗X1*)

You're on your own for the quaternion square root. There are lots of ways to do it, and the best will depend on your application, considering speed and stability.

--hth,
Fred Klingener

这篇关于将单位向量转换为四元数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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