<?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 Re: What is different between PostMultiplyBy and PreMultiplyBy in Inventor API? in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13032708#M172018</link>
    <description>&lt;P&gt;This question is related to matrix multiplication. I'm not mathematician and I don't want to explain why it works and how the matrix multiplication is realized. For mathematical background see another resource (for example &lt;A href="https://en.wikipedia.org/wiki/Matrix_multiplication" target="_blank"&gt;wikipedia&lt;/A&gt; is good source)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;But few facts from theory is required.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1) Multiplication of matrices is &lt;U&gt;not commutative&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you have two real numbers &lt;EM&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;&lt;/EM&gt; then &lt;EM&gt;&lt;STRONG&gt;a*b = b*a&lt;/STRONG&gt;&lt;/EM&gt;. -&amp;gt; Is&amp;nbsp;commutative&lt;/LI&gt;&lt;LI&gt;This is not true for matrices. If you have two matrices &lt;EM&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/EM&gt; then &lt;EM&gt;&lt;STRONG&gt;A*B =/= B*A&lt;/STRONG&gt;&lt;/EM&gt;. -&amp;gt; &lt;STRONG&gt;Is NOT commutative&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;2)&amp;nbsp;You can change multiplication order&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;(A*B)*C = A*(B*C)&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Few facts of transformation matrices&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1) Multiplication of matrices may not be always defined. But for transformation matrices is defined every time.&lt;/P&gt;&lt;P&gt;2) Transformation matrices describes individual moves (rotation and translation) and can combine them to single complex move.&lt;/P&gt;&lt;P&gt;3) Each simple move is always defined in object's coordinate system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What API Methods does:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Following API method multiplies two matrices in defined order&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-07D1B8E8-5B14-4A7E-8805-577BF4DD22D8" target="_blank"&gt;PostMutiplyBy&lt;/A&gt;:&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;A.PostMutiplyBy(B) =&amp;gt; A*B&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-73CCB14A-A7BE-405D-A2A2-79B80557D66A" target="_blank"&gt;PreMultiplyBy&lt;/A&gt;: &lt;EM&gt;&lt;STRONG&gt;A.PreMultiplyBy(B) =&amp;gt; B*A&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Practical impacts&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Let you have two transformation matrices &lt;EM&gt;&lt;STRONG&gt;Tx&lt;/STRONG&gt;&lt;/EM&gt; which describes translation in &lt;EM&gt;&lt;STRONG&gt;X&lt;/STRONG&gt;&lt;/EM&gt; direction and &lt;EM&gt;&lt;STRONG&gt;Tr&lt;/STRONG&gt;&lt;/EM&gt; which describes rotation about object's origin of PI/4 rad (45 deg counter clockwise) and &lt;EM&gt;&lt;STRONG&gt;block&lt;/STRONG&gt;&lt;/EM&gt; which can be transformed by matrix &lt;EM&gt;&lt;STRONG&gt;T&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Situation 1&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In this situation we apply translation first and then apply rotation&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;T = Tx * Tr&lt;/STRONG&gt;&lt;/EM&gt;. The result will look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelNavara_0-1726815367518.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1411493i6A4D2834382090D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelNavara_0-1726815367518.png" alt="MichaelNavara_0-1726815367518.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Situation 2&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In this situation we apply rotation first and then apply translation&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;T = Tr * Tx&lt;/STRONG&gt;&lt;/EM&gt;. The result will look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelNavara_1-1726815487813.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1411494i8B39B3CFF8B9CA5E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelNavara_1-1726815487813.png" alt="MichaelNavara_1-1726815487813.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code sample for testing&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'Initialization
Dim part As PartDocument = ThisDoc.Document
Dim sketch As PlanarSketch = part.ComponentDefinition.Sketches(1)
Dim block As SketchBlock = sketch.SketchBlocks(1)

'Setup matrices
Dim translationMtx As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()
Dim translationVector As Vector2d = ThisApplication.TransientGeometry.CreateVector2d(3, 0)
translationMtx.SetTranslation(translationVector)

Dim rotationMtx As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()
Dim center As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
rotationMtx.SetToRotation(Math.PI / 4, center)

Dim invertedRotationMtx = rotationMtx.Copy()
invertedRotationMtx.Invert()

Dim blockTransformation As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()

'Uncomment following situations for testing

'Situation 1
'  with PostMultiplyBy
blockTransformation.PostMultiplyBy(translationMtx) 	'Tx
blockTransformation.PostMultiplyBy(rotationMtx)		'Tr

''Situation 2
''  with PostMultiplyBy
'blockTransformation.PostMultiplyBy(rotationMtx)	'Tr
'blockTransformation.PostMultiplyBy(translationMtx)	'Tx


''Situation 2
''  with PreMultiplyBy
'blockTransformation.PostMultiplyBy(translationMtx)	'Tx
'blockTransformation.PreMultiplyBy(rotationMtx)		'Tr


block.Transformation = blockTransformation

ThisApplication.ActiveView.Update&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>Fri, 20 Sep 2024 07:26:13 GMT</pubDate>
    <dc:creator>Michael.Navara</dc:creator>
    <dc:date>2024-09-20T07:26:13Z</dc:date>
    <item>
      <title>What is different between PostMultiplyBy and PreMultiplyBy in Inventor API?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13032168#M172012</link>
      <description>&lt;P&gt;Hi, Exports,&lt;/P&gt;&lt;P&gt;Recently, I looked into below 2 threads on PreMultiplyBy and PostMultiplyBy. Both of these Inventor API functions can apply to Matrix and do multiple rotations, what is different between these two functions? what is different between the results after their operations?&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-programming-ilogic/combining-multiple-rotations/m-p/7553161" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-programming-ilogic/combining-multiple-rotations/m-p/7553161&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-programming-ilogic/rotate-block-in-part-sketch/td-p/13026176" target="_blank"&gt;https://forums.autodesk.com/t5/inventor-programming-ilogic/rotate-block-in-part-sketch/td-p/13026176&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 00:04:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13032168#M172012</guid>
      <dc:creator>liminma8458</dc:creator>
      <dc:date>2024-09-20T00:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: What is different between PostMultiplyBy and PreMultiplyBy in Inventor API?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13032708#M172018</link>
      <description>&lt;P&gt;This question is related to matrix multiplication. I'm not mathematician and I don't want to explain why it works and how the matrix multiplication is realized. For mathematical background see another resource (for example &lt;A href="https://en.wikipedia.org/wiki/Matrix_multiplication" target="_blank"&gt;wikipedia&lt;/A&gt; is good source)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;But few facts from theory is required.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1) Multiplication of matrices is &lt;U&gt;not commutative&lt;/U&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;If you have two real numbers &lt;EM&gt;&lt;STRONG&gt;a&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;b&lt;/STRONG&gt;&lt;/EM&gt; then &lt;EM&gt;&lt;STRONG&gt;a*b = b*a&lt;/STRONG&gt;&lt;/EM&gt;. -&amp;gt; Is&amp;nbsp;commutative&lt;/LI&gt;&lt;LI&gt;This is not true for matrices. If you have two matrices &lt;EM&gt;&lt;STRONG&gt;A&lt;/STRONG&gt;&lt;/EM&gt; and &lt;EM&gt;&lt;STRONG&gt;B&lt;/STRONG&gt;&lt;/EM&gt; then &lt;EM&gt;&lt;STRONG&gt;A*B =/= B*A&lt;/STRONG&gt;&lt;/EM&gt;. -&amp;gt; &lt;STRONG&gt;Is NOT commutative&lt;/STRONG&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;2)&amp;nbsp;You can change multiplication order&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;(A*B)*C = A*(B*C)&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Few facts of transformation matrices&lt;/U&gt;&lt;/P&gt;&lt;P&gt;1) Multiplication of matrices may not be always defined. But for transformation matrices is defined every time.&lt;/P&gt;&lt;P&gt;2) Transformation matrices describes individual moves (rotation and translation) and can combine them to single complex move.&lt;/P&gt;&lt;P&gt;3) Each simple move is always defined in object's coordinate system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What API Methods does:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Following API method multiplies two matrices in defined order&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-07D1B8E8-5B14-4A7E-8805-577BF4DD22D8" target="_blank"&gt;PostMutiplyBy&lt;/A&gt;:&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;A.PostMutiplyBy(B) =&amp;gt; A*B&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-73CCB14A-A7BE-405D-A2A2-79B80557D66A" target="_blank"&gt;PreMultiplyBy&lt;/A&gt;: &lt;EM&gt;&lt;STRONG&gt;A.PreMultiplyBy(B) =&amp;gt; B*A&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Practical impacts&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;Let you have two transformation matrices &lt;EM&gt;&lt;STRONG&gt;Tx&lt;/STRONG&gt;&lt;/EM&gt; which describes translation in &lt;EM&gt;&lt;STRONG&gt;X&lt;/STRONG&gt;&lt;/EM&gt; direction and &lt;EM&gt;&lt;STRONG&gt;Tr&lt;/STRONG&gt;&lt;/EM&gt; which describes rotation about object's origin of PI/4 rad (45 deg counter clockwise) and &lt;EM&gt;&lt;STRONG&gt;block&lt;/STRONG&gt;&lt;/EM&gt; which can be transformed by matrix &lt;EM&gt;&lt;STRONG&gt;T&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Situation 1&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In this situation we apply translation first and then apply rotation&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;T = Tx * Tr&lt;/STRONG&gt;&lt;/EM&gt;. The result will look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelNavara_0-1726815367518.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1411493i6A4D2834382090D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelNavara_0-1726815367518.png" alt="MichaelNavara_0-1726815367518.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Situation 2&lt;/U&gt;&lt;/P&gt;&lt;P&gt;In this situation we apply rotation first and then apply translation&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;T = Tr * Tx&lt;/STRONG&gt;&lt;/EM&gt;. The result will look like this&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelNavara_1-1726815487813.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1411494i8B39B3CFF8B9CA5E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelNavara_1-1726815487813.png" alt="MichaelNavara_1-1726815487813.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code sample for testing&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;'Initialization
Dim part As PartDocument = ThisDoc.Document
Dim sketch As PlanarSketch = part.ComponentDefinition.Sketches(1)
Dim block As SketchBlock = sketch.SketchBlocks(1)

'Setup matrices
Dim translationMtx As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()
Dim translationVector As Vector2d = ThisApplication.TransientGeometry.CreateVector2d(3, 0)
translationMtx.SetTranslation(translationVector)

Dim rotationMtx As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()
Dim center As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
rotationMtx.SetToRotation(Math.PI / 4, center)

Dim invertedRotationMtx = rotationMtx.Copy()
invertedRotationMtx.Invert()

Dim blockTransformation As Matrix2d = ThisApplication.TransientGeometry.CreateMatrix2d()

'Uncomment following situations for testing

'Situation 1
'  with PostMultiplyBy
blockTransformation.PostMultiplyBy(translationMtx) 	'Tx
blockTransformation.PostMultiplyBy(rotationMtx)		'Tr

''Situation 2
''  with PostMultiplyBy
'blockTransformation.PostMultiplyBy(rotationMtx)	'Tr
'blockTransformation.PostMultiplyBy(translationMtx)	'Tx


''Situation 2
''  with PreMultiplyBy
'blockTransformation.PostMultiplyBy(translationMtx)	'Tx
'blockTransformation.PreMultiplyBy(rotationMtx)		'Tr


block.Transformation = blockTransformation

ThisApplication.ActiveView.Update&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>Fri, 20 Sep 2024 07:26:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13032708#M172018</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2024-09-20T07:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: What is different between PostMultiplyBy and PreMultiplyBy in Inventor API?</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13034662#M172054</link>
      <description>&lt;P&gt;Hi, Michael,&lt;/P&gt;&lt;P&gt;Thank you so much for the test sample! I will research on that.&lt;/P&gt;&lt;P&gt;Great with the definition. That is something I want confirmation for a long time.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-07D1B8E8-5B14-4A7E-8805-577BF4DD22D8&amp;amp;_ga=2.207800274.1381920990.1726665706-1686609936.1714745739" target="_blank" rel="nofollow noopener noreferrer"&gt;PostMutiplyBy&lt;/A&gt;:&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;A.PostMutiplyBy(B) =&amp;gt; A*B&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-73CCB14A-A7BE-405D-A2A2-79B80557D66A" target="_blank" rel="nofollow noopener noreferrer"&gt;PreMultiplyBy&lt;/A&gt;: &lt;EM&gt;&lt;STRONG&gt;A.PreMultiplyBy(B) =&amp;gt; B*A&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Thumb up!&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Sep 2024 01:49:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/what-is-different-between-postmultiplyby-and-premultiplyby-in/m-p/13034662#M172054</guid>
      <dc:creator>liminma8458</dc:creator>
      <dc:date>2024-09-21T01:49:08Z</dc:date>
    </item>
  </channel>
</rss>

