转换本地四元数旋转到全球(陀螺仪) [英] Translate Local quaternion rotation into global (gyro)
问题描述
我需要一种方式来获得欧拉角为参考,从本地全局框架旋转。我使用C#,WPF 3D和陀螺仪。予具有应以同样的方式作为陀螺仪在屏幕上移动的地球仪。由于陀螺仪将相对运动本身我需要使用四元数,以保持对象的状态和更新,但我坚持。如果我做了以下内容:
VAR曲= eulerToQ(Gyro.X,Gyro.Y,Gyro.Z);
GlobalQu = Quaternion.Multiply(曲,GlobalQu);
IT正确旋转在一个轴上。当我在一个方向中的另一个转动由A,然后由乙对象和陀螺仪的旋转不再在相同的方向,因为绝对旋转上述工程(相对于世界)。
例如:
VAR曲= eulerToQ(KeyboardValue1,KeyboardValue2,KeyboardValue3);
GlobalQu =渠;
这工作,因为我是通过键盘上的全球轴上增加侧倾,俯仰,偏航即键盘值始终。陀螺仪在局部轴旋转发送
切换四元轮换次序没有帮助
VAR曲= eulerToQ(Giro.X,Giro.Y,Giro.Z);
GlobalQu = Quaternion.Multiply(GlobalQu,曲);
这其实是正确的方式。如果你乘globalQuaternion * newQuaternion你得到全球的旋转和newQuaternion * globalQuaternion那么你得到局部旋转。我根本就在创造我的四元数错了。
I need a way to get euler angles for rotation in global frame of reference from a local. I am using c#, wpf 3d and a gyroscope. I have a globe on the screen that should move in the same way as the gyro. Since the gyro sends movement relative to itself I need to use quaternions to keep the state of the object and update it but I'm stuck. If i do the following:
var qu=eulerToQ(Gyro.X,Gyro.Y,Gyro.Z);
GlobalQu = Quaternion.Multiply(qu, GlobalQu);
IT rotates correctly on one axis. When I rotate by A in one direction and then by B in another the rotations of the object and the gyro are no longer in the same direction because the above works for absolute rotations (relative to the world).
For example:
var qu=eulerToQ(KeyboardValue1,KeyboardValue2,KeyboardValue3);
GlobalQu = qu;
This works because I am increasing the roll,pitch,yaw ie keyboard values via keyboard always on the global axis. Gyro send rotations on LOCAL axis.
Switching the order of quaternion rotation doesn't help
var qu=eulerToQ(Giro.X,Giro.Y,Giro.Z);
GlobalQu = Quaternion.Multiply(GlobalQu,qu);
This actually is the proper way. If you multiply globalQuaternion * newQuaternion you get global rotation and newQuaternion * globalQuaternion then you get local rotation. I simply had a mistake in generating my quaternion.
这篇关于转换本地四元数旋转到全球(陀螺仪)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!