简体   繁体   English

如何检索每个轴上的3D旋转角度?

[英]How to retrieve the 3D rotation angle on each axis?

I have a Model3DGroup which is rotated around any of the x, y, z axis using an AxisAngleRotation3D applied on the Transform property of the object. 我有一个Model3DGroup,它使用在对象的Transform属性上应用的AxisAngleRotation3D围绕任何x,y,z轴旋转。

The problem is that I am not in control of the various rotations applied on the mesh. 问题是我无法控制网格上应用的各种旋转。 I need to display the angle of the mesh on each of the x, y, z axis at each render loop. 我需要在每个渲染循环的每个x,y,z轴上显示网格的角度。

How can I do that? 我怎样才能做到这一点? I tried retrieving the AxisAngleRotation3D object on the object, but it only gives me the rotation that was last applied. 我尝试在对象上检索AxisAngleRotation3D对象,但它只给出了上次应用的旋转。 Which is not correct. 哪个不对。

If for example there was an applied rotation of Axis: Vector3D(1, 1, 0) Angle: 45 例如,如果应用了Axis的旋转:Vector3D(1,1,0)角度:45

The actual rotation around Z axis would not be 0. How can I get the actual angle on each axis? 绕Z轴的实际旋转不是0.如何获得每个轴上的实际角度?

 double rotationX = Vector3D.AngleBetween(new Vector3D(1, 0, 0), yourMatrix3D.Transform(new Vector3D(1, 0, 0)));
 double rotationY = Vector3D.AngleBetween(new Vector3D(0, 1, 0), yourMatrix3D.Transform(new Vector3D(0, 1, 0)));
 double rotationZ = Vector3D.AngleBetween(new Vector3D(0, 0, 1), yourMatrix3D.Transform(new Vector3D(0, 0, 1)));

The Model3DGroup.Transform.Value property is a Matrix3D representing the complete transform. Model3DGroup.Transform.Value属性是表示完整转换的Matrix3D。 http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.matrix3d.aspx http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.matrix3d.aspx

The elements of the matrix represent the complete transform. 矩阵的元素代表完整的变换。 The conversion from matrix form to rotation angles (Euler angles) is quite straightforward. 从矩阵形式到旋转角度(欧拉角度)的转换非常简单。 See for example http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm 参见例如http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToEuler/index.htm

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

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