简体   繁体   中英

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

 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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