计算四元数在两个位置坐标2点对象 [英] calculate quaternion by coordinate 2 points of object in two positions
问题描述
在三维物体旋转。我有旋转中心和坐标2点在旋转和不可旋转的位置。计算四元数的旋转物体从第一位置移动到第二的位置。
Object rotate in 3D. I have rotation center and coordinate of 2 point in rotate and not rotate position. Calculate quaternion that rotate object from first position to two position.
推荐答案
我们必须在对象
第一位置向量OA'和OB
OA和OB在第二位置
Q矢量部分四元数Q 0 标部分
We have to vector OA' and OB' in first position of object
OA and OB in second position
Q vector part quaternion Q0 scalar part
图1
注释
OA·OB - 点向量积
OAxOB - 跨向量积
从第一现在的位置四元数旋转的对象第二是:
1的情况下
如果OA * OB'-OB * OA'不等于零,那么
Q = Q <子> 0 子> * [(OA-OA')×(OB-OB')] / [OA * OB'-OA'* OB],
其中Q <子> 0 子> -2 =([(OA-OA')×(OB-OB')] / [OA * OB'-OA'* OB])< SUP> 2 +1
如果OA * OB'-OB OA *'= 0,则
2的情况下
如果[OA'+ OA]×[OB'+ OB]不等于零和OB-OB不等于零,
然后
有米的OA-OA'= M *(OB-OB)。搜索。
Q = N *(M * OB'+ OA),
其中n = Q 0 *(OB-OB') 2 /(2 * OB * [OA'xOB'])
Q0-2=(OB-OB')4*(OB'+OA')2/(2*OB*[OA'xOB'])2+1
如果OA * OB'-OB * OA'= 0和[OA + OA']×[OB + OB'] = 0
3的情况下
如果OB + OB'not等于零,那么
Q =(OB + OB')/ | OB + OB'|,Q 0 = 0
否则
4的情况下
OB + OB'= 0
Q =([OB']×[OA'])/ | [OB']×[OA] |,Q 0 = 0
从四元数,我们可以计算出旋转矩阵或欧拉角
fig.1
COMMENT
OA*OB - dot vector product
OAxOB - cross vector product
Quaternion of rotation object from first positon to second was:
1 case
If OA*OB'-OB*OA' not equal zero, then
Q=Q0*[(OA-OA')x(OB-OB')]/[OA*OB'-OA'*OB],
where Q0-2=([(OA-OA')x(OB-OB')]/[OA*OB'-OA'*OB])2+1
If OA*OB'-OB*OA'=0, then
2 case
if [OA'+OA]x[OB'+OB] not equal zero and OB-OB' not equal zero,
then
exist m that OA-OA'=m*(OB-OB'). Search it.
Q=n*(m*OB'+OA'),
where n=Q0*(OB-OB')2/(2*OB*[OA'xOB'])
Q0-2=(OB-OB')4*(OB'+OA')2/(2*OB*[OA'xOB'])2+1
If OA*OB'-OB*OA'=0 and [OA+OA']x[OB+OB']=0
3 case
If OB+OB'not equal zero, then
Q=(OB+OB')/|OB+OB'|, Q0=0
else
4 case
OB+OB'=0
Q=([OB']x[OA'])/|[OB']x[OA']|, Q0=0
From quaternion we can calculate rotation matrix or Euler angles
这篇关于计算四元数在两个位置坐标2点对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!