ok I found out that actual multiplication is no problem, my problem lies with storing the end result.<br><br>This works:<br><br>&nbsp; typedef itk::Matrix&lt;double,3,4&gt; Matrix3by4Type;<br>&nbsp; typedef itk::Vector&lt;double,4&gt; Vector4Type;<br>

<br>&nbsp; Matrix3by4Type Translation;<br>&nbsp; Vector4Type FinalOrigin;<br><br>&nbsp; Translation[0][0] = 1; Translation[0][1] = 0; Translation[0][2] = 0; Translation[0][3] = 2;<br>&nbsp; Translation[1][0] = 0; Translation[1][1] = 1; Translation[1][2] = 0; Translation[1][3] = 3;<br>

&nbsp; Translation[2][0] = 0; Translation[2][1] = 0; Translation[2][2] = 1; Translation[2][3] = 4;<br><br>&nbsp; FinalOrigin[0] = 0; FinalOrigin[1] = 0; FinalOrigin[2] = 0; FinalOrigin[3] = 1;<br><br>&nbsp; std::cout &lt;&lt; &quot;finalorigin: &quot; &lt;&lt; std::endl &lt;&lt; FinalOrigin &lt;&lt; std::endl;<br>

&nbsp; std::cout &lt;&lt; &quot;translation: &quot; &lt;&lt; std::endl &lt;&lt; Translation &lt;&lt; std::endl;<br><br>&nbsp; std::cout &lt;&lt; &quot;p :&nbsp;&nbsp; &quot;&nbsp;&nbsp; &lt;&lt; FinalOrigin&nbsp;&nbsp; &lt;&lt; std::endl ;<br>&nbsp; std::cout &lt;&lt; &quot;A&lowast;p : &quot; &lt;&lt; Translation*FinalOrigin &lt;&lt; std::endl ;<br>

<br><br>// but this doesn&#39;t work:<br>&nbsp; <br>&nbsp;FinalOrigin = A*p<br><br><br>When I make the vector a 1by4 Matrix instead:<br><br>FinalOrigin *= Translation;<br>&nbsp;compile error: no match for &lsquo;operator*=&rsquo; in &lsquo;FinalOrigin *= Translation&rsquo;<br>

<br>&nbsp;FinalOrigin *= Translation.GetTranspose();<br><br>runtime error:<br>vnl_matrix_fixed&lt;T, num_rows, num_cols&gt;::vnl_matrix_fixed(const vnl_matrix&lt;T&gt;&amp;) [with T = double, unsigned int num_rows = 4u, unsigned int num_cols = 4u]: Assertion `rhs.rows() == num_rows &amp;&amp; rhs.columns() == num_cols&#39; failed.<br>

(which makes sense because the the number of rows and colums of both the vector and matrix are not the same)<br><br>So vector still seems to be the right way to go, I just can&#39;t figure out how to save it in a vector...<br>

<br><br>Does anybody know how I save my result?<br><br>cheers, Michael<br><br><br><br><br><div class="gmail_quote">On Wed, Mar 31, 2010 at 10:21 AM, michiel mentink <span dir="ltr">&lt;<a href="mailto:michael.mentink@st-hughs.ox.ac.uk">michael.mentink@st-hughs.ox.ac.uk</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>I&#39;d like to do the following calculation, a translate:<br><br>A =<br>[ 1&nbsp; 0&nbsp; 0&nbsp; 2 ]<br>

[ 0&nbsp; 1&nbsp; 0&nbsp; 3 ]<br>[ 0&nbsp; 0&nbsp; 1&nbsp; 4 ]<br><br>B = [ x y z 1 ]<br><br>FinalOrigin = A * B&#39; = [x+2 y+3 z+4 ]<br><br>For that, I have got the following code:<br>
<br><br><br><span style="font-family: times new roman,serif;">&nbsp; typedef itk::Matrix&lt;double,3,4&gt; Matrix3by4Type;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">&nbsp; typedef itk::Vector&lt;double,4&gt; Vector4Type;</span><br style="font-family: times new roman,serif;">


<br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">&nbsp; Matrix3by4Type Translation;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">&nbsp; Vector4Type &nbsp; &nbsp;&nbsp; FinalOrigin;</span><br>


<br><span style="font-family: times new roman,serif;">FinalOrigin[0] = origin[0]; FinalOrigin[1] = origin[1]; FinalOrigin[2] = origin[2]; FinalOrigin[3] = 1;</span><br style="font-family: times new roman,serif;"><span style="font-family: times new roman,serif;">FinalOrigin = Translation * FinalOrigin;</span><br style="font-family: times new roman,serif;">


<br><br><br>1)<br>Is it possible to multiply an itk::vector with an itk::matrix in ITK?<br><br>2)<br>There is no transpose available for the vnl_vector type, that is implemented in ITK. <br>Or is there?<br><br><br>I know that there are other methods in ITK to do translation, but for my understanding, I&#39;d like<br>


to figure this out.<br><br>cheers, <br><br>Michael<br><br><br><br>
</blockquote></div><br>