<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Discrepancy between Matrix3d.Rotation and Matrix3D.RotateAt in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9570234#M19395</link>
    <description>&lt;P&gt;I'm trying to port some code from the AutoCAD API to a more generic .Net API and I found a discrepancy between two functions that are supposed to do the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In AutoCAD, I created an AutoCAD.Geometry.Matrix3d object and then rotated it about the Z Axis by AnglePhi (PI/8). Here's the code snippet.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixZAxis As Autodesk.AutoCAD.Geometry.Matrix3d
RotationMatrixZAxis = Autodesk.AutoCAD.Geometry.Matrix3d.Rotation(AnglePhi, New Autodesk.AutoCAD.Geometry.Vector3d(0, 0, 1), New Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant element values from this operation are: 1,1 = 0.9238, 1,2 = -0.3826, 1,3 = 0, 2,1 = 0.3826, 2,2 = 0.9238, 2,3 = 0, 3,1 = 0, 3,2 = 0, 3,3 = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I do the same thing using the System.Windows.Media.Media3D library.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixZAxis As New System.Windows.Media.Media3D.Matrix3D
Dim MyQuaternion As New System.Windows.Media.Media3D.Quaternion(New Vector3D(0, 0, 1), AnglePhi * 180 / PI)
RotationMatrixYAxis.RotateAt(MyQuaternion, New Point3D(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant element values from this operation are: 1,1 = 0.9238, 1,2 = 0.3826, 1,3 = 0, 2,1 = -0.3826, 2,2 = 0.9238, 2,3 = 0, 3,1 = 0, 3,2 = 0, 3,3 = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the rotation matrix using the System.Windows.Media.Media3D library is the inverse of the rotation matrix using Autodesk.AutoCAD.Geometry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain to me why this is? My code porting project is stopped dead in its tracks until I get this little mystery solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren Haverstick&lt;/P&gt;&lt;P&gt;Paul Mueller Company&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jun 2020 19:03:21 GMT</pubDate>
    <dc:creator>dhaverstick</dc:creator>
    <dc:date>2020-06-09T19:03:21Z</dc:date>
    <item>
      <title>Discrepancy between Matrix3d.Rotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9570234#M19395</link>
      <description>&lt;P&gt;I'm trying to port some code from the AutoCAD API to a more generic .Net API and I found a discrepancy between two functions that are supposed to do the same thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In AutoCAD, I created an AutoCAD.Geometry.Matrix3d object and then rotated it about the Z Axis by AnglePhi (PI/8). Here's the code snippet.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixZAxis As Autodesk.AutoCAD.Geometry.Matrix3d
RotationMatrixZAxis = Autodesk.AutoCAD.Geometry.Matrix3d.Rotation(AnglePhi, New Autodesk.AutoCAD.Geometry.Vector3d(0, 0, 1), New Autodesk.AutoCAD.Geometry.Point3d(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant element values from this operation are: 1,1 = 0.9238, 1,2 = -0.3826, 1,3 = 0, 2,1 = 0.3826, 2,2 = 0.9238, 2,3 = 0, 3,1 = 0, 3,2 = 0, 3,3 = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I do the same thing using the System.Windows.Media.Media3D library.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixZAxis As New System.Windows.Media.Media3D.Matrix3D
Dim MyQuaternion As New System.Windows.Media.Media3D.Quaternion(New Vector3D(0, 0, 1), AnglePhi * 180 / PI)
RotationMatrixYAxis.RotateAt(MyQuaternion, New Point3D(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant element values from this operation are: 1,1 = 0.9238, 1,2 = 0.3826, 1,3 = 0, 2,1 = -0.3826, 2,2 = 0.9238, 2,3 = 0, 3,1 = 0, 3,2 = 0, 3,3 = 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the rotation matrix using the System.Windows.Media.Media3D library is the inverse of the rotation matrix using Autodesk.AutoCAD.Geometry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone explain to me why this is? My code porting project is stopped dead in its tracks until I get this little mystery solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren Haverstick&lt;/P&gt;&lt;P&gt;Paul Mueller Company&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jun 2020 19:03:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9570234#M19395</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-09T19:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix3d.Rotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9576500#M19396</link>
      <description>&lt;P&gt;To help illustrate what I am talking about, I have attached VS 2019 project that creates an AutoCAD addin. The addin is compiled for AutoCAD 2019. All source code is included.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To run the addin, use the NETLOAD command, navigate to the ".\bin\Release\" folder, and choose the library, "QuaternionAutoCADExample.dll". After the library is loaded, invoke the command, "RUNQUATERNIONEXAMPLE".&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren Haverstick&lt;/P&gt;&lt;P&gt;Paul Mueller Company&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 13:29:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9576500#M19396</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-12T13:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix3d.Rotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9578093#M19397</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From some tests I did,you're right. System.Windows.Media.Media3D represents the &lt;STRIKE&gt;inversed&lt;/STRIKE&gt; transposed transformation matrix. But when you use it (e.g. apply it to a vector), it returns the same result as the Autodesk.AutoCAD.Geometry one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this example:&lt;/P&gt;
&lt;P&gt;AcGe = Autodesk.AutoCAD.Geometry&lt;BR /&gt;WM3D = System.Windows.Media.Media3D&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod("TEST")]
public static void Test()
{
    var ed = AcAp.DocumentManager.MdiActiveDocument.Editor;

    var m1 = AcGe.Matrix3d.Rotation(Math.PI / 8.0, AcGe.Vector3d.ZAxis, AcGe.Point3d.Origin);
    var v1 = new AcGe.Vector3d(3.0, 2.0, 0.0).TransformBy(m1);
    ed.WriteMessage($"\nAutoCAD\n{m1:0.000}\n{v1:0.000}");

    var quaternion = new WM3D.Quaternion(new WM3D.Vector3D(0.0, 0.0, 1.0), 22.5);
    var m2 = new WM3D.Matrix3D();
    m2.Rotate(quaternion);
    var v2 = WM3D.Vector3D.Multiply(new WM3D.Vector3D(3.0, 2.0, 0.0), m2);
    ed.WriteMessage($"\nMedia3D\n{m2:0.000}\n{v2:0.000}");
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;AutoCAD
((0.924,-0.383,0.000,0.000),(0.383,0.924,0.000,0.000),(0.000,0.000,1.000,0.000),(0.000,0.000,0.000,1.000))
(2.006,2.996,0.000)
Media3D
0.924,0.383,0.000,0.000,-0.383,0.924,0.000,0.000,0.000,0.000,1.000,0.000,0.000,0.000,0.000,1.000
2.006,2.996,0.000&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Jun 2020 15:12:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9578093#M19397</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2020-06-13T15:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix3d.Rotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9582424#M19398</link>
      <description>&lt;P&gt;Gilles, you are correct! I did not go any further in my testing because I wanted an explanation about the discrepancy first. It appears that it all works out in the end so no harm, no foul.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are also correct that the correct term is one matrix is the transpose of the other. I'm not sure why the Media3D version uses a method called "Invert" to return the transpose.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren Haverstick&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 12:59:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/discrepancy-between-matrix3d-rotation-and-matrix3d-rotateat/m-p/9582424#M19398</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-16T12:59:20Z</dc:date>
    </item>
  </channel>
</rss>

