开发者

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.

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 g开发者_StackOverflowives 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?


 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. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜