WPF 3D多重旋转 [英] WPF 3D Multiple Rotations

查看:369
本文介绍了WPF 3D多重旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在用wpf对3D船进行建模.我具有按度数更改俯仰,航向和横滚(模型的x,y,z)的功能.这些使用单独的变换,例如:

RotateTransform.Rotation = new AxisAngleRotation3D(new Vector3D(1,0,0),pitchangle);

当我应用例如航向/y变换然后进行roll/z变换时,旋转轴是不正确的,因为它绕3D空间的z轴而不是模型(现在已更改)z轴旋转.

Hi,

I''m modelling a ship in 3D in wpf. I have functions to change pitch, heading and roll, (model''s x,y,z), by degrees. These use individual transforms, such as:

RotateTransform.Rotation = new AxisAngleRotation3D(new Vector3D(1, 0, 0), pitchangle);

Its obvious when I apply for instance a heading/y transform then a roll/z transform the rotation axis isn''t right as it''s rotating round the 3D space''s z axis not the models (now changed) z axis.

How do keep track of the correct rotation axis for the model?

推荐答案

改用四元数.您会遇到各种奇怪的行为,包括万能锁 [ http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation [ http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095 [
Use quaternions instead. You''ll run into all sorts of weird behaviour, including gimbal lock[^] when using Euler angles.

http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation[^]

http://www.gamedev.net/page/resources/_/technical/math-and-physics/quaternion-powers-r1095[^]


It might seem like a big step to move to Quaternions, but trust me, it will pay off.

Hope this helps,
Fredrik


这篇关于WPF 3D多重旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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