WPF 3D:如何将单个AxisAngleRotation3D到单独AxisAngleRotation3D?如何将、WPF、AxisAngleRotation3D

2023-09-08 10:28:51 作者:人群恐惧

我有一个使用WPF的3D工具的轨迹球鼠标旋转物体的3D视图。这样一来,我与轴矢量像(0.5,0.2,0.6)和EG的角度单一AxisAngleRotation3D 35.这很好。

I have a 3D viewport that uses the TrackBall of WPF 3D tool to rotate the object by mouse. As a result, I get a single AxisAngleRotation3D with Axis vector like (0.5, 0.2, 0.6) and Angle of e.g. 35. That's fine.

我想要做的是,作为一种替代,让用户可以通过旋转轴个别对象的能力(即X,Y,Z)。因此,如果目的是通过35度左右(0.5,0.2,0.6)的轴旋转时,如何可以转换成围绕每个轴,即三个旋转此。 Xangle为矢量(1,0,0),Yangle为矢量(0,1,0),和Zangle为矢量(0,0,1)。

What I would like to do is, as an alternative, to give user the ability to rotate the object by individual axis (i.e. x, y, z). So, if the object is rotated around the axis of (0.5, 0.2, 0.6) by 35 degree, how can I convert this into three rotations around each axis, ie. Xangle for vector (1, 0, 0), Yangle for vector (0, 1, 0), and Zangle for vector (0, 0, 1).

我还需要一种方法将其转换回单AxisAngleRotation3D对象。

I also need a way to convert them back to a single AxisAngleRotation3D object.

修改

我发现了一些东西,在 http://www.gamedev.net/reference/articles /article1095.asp 。有一件事我学到的是,我可以很容易地从separete AxisAngleRotation3D A(合并)四元数。例如,

I found some stuff at http://www.gamedev.net/reference/articles/article1095.asp. One thing I learnt is that I can easily get a (combined) quaternion from separete AxisAngleRotation3D. For example,

        private AxisAngleRotation3D _axisX = new AxisAngleRotation3D();
        private AxisAngleRotation3D _axisY = new AxisAngleRotation3D();
        private AxisAngleRotation3D _axisZ = new AxisAngleRotation3D();
...
            _axisX.Axis = new Vector3D(1, 0, 0);
            _axisY.Axis = new Vector3D(0, 1, 0);
            _axisZ.Axis = new Vector3D(0, 0, 1); 
...
            Quaternion qx = new Quaternion(_axisX.Axis, _axisX.Angle);
            Quaternion qy = new Quaternion(_axisY.Axis, _axisY.Angle);
            Quaternion qz = new Quaternion(_axisZ.Axis, _axisZ.Angle);
            Quaternion q = qx * qy * qz;

这是好的。现在的问题是我该怎么办相反?因此,对于一个给定的Q,我怎么能找到QX,QY,QZ?

This is fine. Now, the problem is how can I do the reverse? So, for a given q, how can I find out qx, qy, qz?

推荐答案

cuanternion到欧拉角

cuanternion to Euler angles