<?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 Matrix.SetToRotation and Matrix3D.RotateAt in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9563541#M111748</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Inventor, I created an Inventor.Matrix and then rotated it about the Y Axis by AnglePhi (PI/8). Here's the code snippet.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixYAxis As Inventor.Matrix = InventorApp.TransientGeometry.CreateMatrix
RotationMatrixYAxis.SetToRotation(AnglePhi, InventorApp.TransientGeometry.CreateVector(0, 1, 0), InventorApp.TransientGeometry.CreatePoint(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant cell values from this operation are:&amp;nbsp;1,1 = 0.9238, 1,2 = 0,&amp;nbsp;1,3 = 0.3826,&amp;nbsp;2,1 = 0,&amp;nbsp;2,2 = 1,&amp;nbsp;2,3 = 0,&amp;nbsp;3,1 = -0.3826,&amp;nbsp;3,2 = 0,&amp;nbsp;3,3 = 0.9238&lt;/P&gt;&lt;P&gt;Now I do the same thing using the System.Numerics and System.Windows.Media.Media3D libraries.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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))
&lt;/LI-CODE&gt;&lt;P&gt;The resultant cell values from this operation are:&amp;nbsp;1,1 = 0.9238, 1,2 = 0,&amp;nbsp;1,3 = -0.3826,&amp;nbsp;2,1 = 0,&amp;nbsp;2,2 = 1,&amp;nbsp;2,3 = 0,&amp;nbsp;3,1 = 0.3826,&amp;nbsp;3,2 = 0,&amp;nbsp;3,3 = 0.9238&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the signs are switched for the elements 1,3 and 3,1 between the two methods of rotation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jun 2020 19:06:29 GMT</pubDate>
    <dc:creator>dhaverstick</dc:creator>
    <dc:date>2020-06-05T19:06:29Z</dc:date>
    <item>
      <title>Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9563541#M111748</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Inventor, I created an Inventor.Matrix and then rotated it about the Y Axis by AnglePhi (PI/8). Here's the code snippet.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim RotationMatrixYAxis As Inventor.Matrix = InventorApp.TransientGeometry.CreateMatrix
RotationMatrixYAxis.SetToRotation(AnglePhi, InventorApp.TransientGeometry.CreateVector(0, 1, 0), InventorApp.TransientGeometry.CreatePoint(0, 0, 0))&lt;/LI-CODE&gt;&lt;P&gt;The resultant cell values from this operation are:&amp;nbsp;1,1 = 0.9238, 1,2 = 0,&amp;nbsp;1,3 = 0.3826,&amp;nbsp;2,1 = 0,&amp;nbsp;2,2 = 1,&amp;nbsp;2,3 = 0,&amp;nbsp;3,1 = -0.3826,&amp;nbsp;3,2 = 0,&amp;nbsp;3,3 = 0.9238&lt;/P&gt;&lt;P&gt;Now I do the same thing using the System.Numerics and System.Windows.Media.Media3D libraries.&lt;/P&gt;&lt;LI-CODE lang="general"&gt;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))
&lt;/LI-CODE&gt;&lt;P&gt;The resultant cell values from this operation are:&amp;nbsp;1,1 = 0.9238, 1,2 = 0,&amp;nbsp;1,3 = -0.3826,&amp;nbsp;2,1 = 0,&amp;nbsp;2,2 = 1,&amp;nbsp;2,3 = 0,&amp;nbsp;3,1 = 0.3826,&amp;nbsp;3,2 = 0,&amp;nbsp;3,3 = 0.9238&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the signs are switched for the elements 1,3 and 3,1 between the two methods of rotation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jun 2020 19:06:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9563541#M111748</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-05T19:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9571461#M111879</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/55431"&gt;@dhaverstick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please provide non confidential VB.net project which includes &lt;SPAN style="color: #1d1c1d; font-family: Slack-Lato, appleLogo, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: common-ligatures; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #f8f8f8; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;System.Windows.Media.Media3D.Quaternion&lt;/SPAN&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 09:50:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9571461#M111879</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2020-06-10T09:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9571826#M111888</link>
      <description>&lt;P&gt;Attached is a zip file containing the project you asked for.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice that the Media3D rotation matrix is always the inverse of the corresponding Inventor matrix.&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>Wed, 10 Jun 2020 12:49:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9571826#M111888</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-10T12:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9573976#M111924</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/55431"&gt;@dhaverstick&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the attached mathgeometry.pdf(refer page number 16 - 23), rotation of occurrence in assembly is clearly explained. Please go through the same. The working of Matrix3D.RotateAt should be checked with Microsoft team.(&lt;A href="https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.media3d.matrix3d.rotateat?view=netcore-3.1#definition" target="_blank" rel="noopener"&gt;https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.media3d.matrix3d.rotateat?view=netcore-3.1#definition&lt;/A&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks and regards,&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 11:21:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9573976#M111924</guid>
      <dc:creator>chandra.shekar.g</dc:creator>
      <dc:date>2020-06-11T11:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9574311#M111929</link>
      <description>&lt;P&gt;I'm not sure what you are trying to tell me with your last reply. I have used Inventor rotation matrices many times. What I am asking for is some insight on why two commands, one Inventor and one .Net, that appear to do the same thing, produce different results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This might better be illustrated with the attached Inventor addin project. This project has the user enter a rotation angle value and choose what axis to rotate about. The results of the rotation matrices are then displayed for both the Inventor Matrix object and the Media3D Matrix3D object. From the results, you can easily see that one matrix is the inverse of the other.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This project is compiled on the Inventor 2019 platform. There is an executable that you can install and run along with all the source code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it helps any, I have done the same comparison with the AutoCAD Geometry.Matrix3d object and the Media3D.Matrix3D object. The results are the same as the Inventor comparison. One matrix is the inverse of the other.&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>Thu, 11 Jun 2020 13:35:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9574311#M111929</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-11T13:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576186#M111963</link>
      <description>&lt;P&gt;Hi Darren,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you encountered any problem with the rotation of Matrix in Inventor(except the values against Matrix3D in .net)? Do you want to rotate some Inventor objects(like ComponentOccurrence, SurfaceBody) but has wrong result with the Matrix.SetToRotation?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 10:52:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576186#M111963</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2020-06-12T10:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576305#M111967</link>
      <description>&lt;P&gt;No, I have not had any issues with using matrices in Inventor. I'm just wanting someone to explain to me why two methods, that appear to do the same thing, produce different results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Darren&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 11:57:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576305#M111967</guid>
      <dc:creator>dhaverstick</dc:creator>
      <dc:date>2020-06-12T11:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Discrepancy between Matrix.SetToRotation and Matrix3D.RotateAt</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576343#M111969</link>
      <description>&lt;P&gt;I am not sure why Microsoft chose that style, but you can refer to some articles like below one to understand what Inventor does for the Matrix's rotation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.continuummechanics.org/rotationmatrix.html" target="_blank"&gt;https://www.continuummechanics.org/rotationmatrix.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Specially for the section "3-D Reduction to 2-D".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any problem with using the Matrix in Inventor please let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:24:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/discrepancy-between-matrix-settorotation-and-matrix3d-rotateat/m-p/9576343#M111969</guid>
      <dc:creator>YuhanZhang</dc:creator>
      <dc:date>2020-06-12T12:24:40Z</dc:date>
    </item>
  </channel>
</rss>

