简体   繁体   English

使用旋转四元数将3d矢量值旋转为单轴

[英]Rotate 3d vector value into a single axis using a rotation quaternion

I want to rotate the whole value of a 3d vector into one axis using quaternion rotations. 我想使用四元数旋转将3d向量的整个值旋转到一个轴上。

The reason behind is that I want to align the X and Y Axis of my smartphone with the X and Y Axis of my vehicle in order to detect lateral and longitudinal acceleration separated on these two axis. 其背后的原因是,我想将智能手机的X和Y轴与车辆的X和Y轴对齐,以便检测在这两个轴上分开的横向和纵向加速度。 Therefore I want to detect the first straight acceleration of the car and rotate the whole acceleration value into the heading axis (X-Axis) of the phone assuming a straight forward motion. 因此,我想检测汽车的第一个直线加速度,并假设直线向前运动,将整个加速度值旋转到手机的前进轴(X轴)上。

How do I achieve this? 我该如何实现?

在此处输入图片说明在此处输入图片说明

I got it myself while this Link helped me a lot. 我自己得到了,而此链接对我有很大帮助。

In the end I just needed to define the destination axis as a Vector V(Magnitude_Source, 0, 0), calculate the angle between V and the source vector and rotate the source vector. 最后,我只需要将目标轴定义为向量V(Magnitude_Source,0,0),计算V与源向量之间的角度并旋转源向量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM