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

拟墨画扇 提交于 2020-01-03 15:19:05

问题


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.

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.

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. Which is not correct.

If for example there was an applied rotation of Axis: Vector3D(1, 1, 0) Angle: 45

The actual rotation around Z axis would not be 0. How can I get the actual angle on each axis?


回答1:


 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)));



回答2:


The Model3DGroup.Transform.Value property is a Matrix3D representing the complete transform. 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



来源:https://stackoverflow.com/questions/4364780/how-to-retrieve-the-3d-rotation-angle-on-each-axis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!