calculate quaternion by coordinate 2 points of object in two positions

冷暖自知 提交于 2019-12-24 12:49:16

问题


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.


回答1:


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

fig.1


COMMENT
OAOB - dot vector product
OAxOB - cross vector product

Quaternion of rotation object from first positon to second was:
1 case
If OA

OB'-OBOA' 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'-OBOA'=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*(mOB'+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 OAOB'-OBOA'=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:


Look at answer to similar question How to find correct rotation from one vector to another?

Your difference that second vector "up" is not perpendicular to first "dir". Just make it and problem solved



来源:https://stackoverflow.com/questions/21771676/calculate-quaternion-by-coordinate-2-points-of-object-in-two-positions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!