Reputation: 133
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?
Upvotes: 5
Views: 5357
Reputation: 4013
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)));
Upvotes: 2
Reputation: 11101
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
Upvotes: 1