Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to port some code from the Inventor API to a more generic .Net API and I found a discrepancy between two functions that are supposed to do the same thing.
In Inventor, I created an Inventor.Matrix and then rotated it about the Y Axis by AnglePhi (PI/8). Here's the code snippet.
Dim RotationMatrixYAxis As Inventor.Matrix = InventorApp.TransientGeometry.CreateMatrix
RotationMatrixYAxis.SetToRotation(AnglePhi, InventorApp.TransientGeometry.CreateVector(0, 1, 0), InventorApp.TransientGeometry.CreatePoint(0, 0, 0))
The resultant cell values from this operation are: 1,1 = 0.9238, 1,2 = 0, 1,3 = 0.3826, 2,1 = 0, 2,2 = 1, 2,3 = 0, 3,1 = -0.3826, 3,2 = 0, 3,3 = 0.9238
Now I do the same thing using the System.Numerics and System.Windows.Media.Media3D libraries.
Dim QuaternionObj As System.Numerics.Quaternion
Dim YAxisVector As New System.Numerics.Vector3(0, 1, 0)
QuaternionObj = System.Numerics.Quaternion.CreateFromAxisAngle(YAxisVector, AnglePhi)
Dim MyQuaternion As System.Windows.Media.Media3D.Quaternion
MyQuaternion = New Quaternion(QuaternionObj.X, QuaternionObj.Y, QuaternionObj.Z, QuaternionObj.W)
Dim RotationMatrixYAxis As New System.Windows.Media.Media3D.Matrix3D
RotationMatrixYAxis.RotateAt(MyQuaternion, New Point3D(0, 0, 0))
The resultant cell values from this operation are: 1,1 = 0.9238, 1,2 = 0, 1,3 = -0.3826, 2,1 = 0, 2,2 = 1, 2,3 = 0, 3,1 = 0.3826, 3,2 = 0, 3,3 = 0.9238
Notice that the signs are switched for the elements 1,3 and 3,1 between the two methods of rotation.
Can anyone explain to me why this is taking place? My code porting project is stopped dead in its tracks until I get this little mystery solved.
Thanks in advance!
Darren Haverstick
Paul Mueller Company