<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hello, <BR>
&nbsp;<BR>
i m wondering if im using the right code to do what i want to do. <BR>
&nbsp;<BR>
i&nbsp;want to used a rotation matrix on my image to rotate my vector over&nbsp;a point. not sure if this&nbsp;is the right code to use.&nbsp;im not specifiying my vector in this code. <BR>
it just take a point as an input, which made me feel like there is something wrong. Is there an easier way to do this? is there a better alternative?<BR>
&nbsp;<BR>
Here is the code, <BR>
&nbsp;<BR><FONT size=2>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>const</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> epsilon = 1e-10;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>const</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> N = 2;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>bool</FONT></FONT><FONT size=2> Ok = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>true</FONT></FONT><FONT size=2>;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>typedef</FONT></FONT><FONT size=2> itk::Euler2DTransform&lt;</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>&gt; EulerTransformType;<BR>
EulerTransformType::Pointer eulerTransform = EulerTransformType::New();<BR>
<BR>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Testing Identity<BR></FONT></FONT><FONT size=2>
std::cout &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Testing identity transform: "</FONT></FONT><FONT size=2>;<BR>
eulerTransform-&gt;SetIdentity();<BR>
EulerTransformType::OffsetType offset = eulerTransform-&gt;GetOffset();<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>( offset[0] != 0.0 <BR>
|| offset[1] != 0.0 <BR>
)<BR>
{<BR>
std::cout &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"[ FAILED ]"</FONT></FONT><FONT size=2> &lt;&lt; std::endl;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> EXIT_FAILURE;<BR>
}<BR>
std::cout &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"[ PASSED ]"</FONT></FONT><FONT size=2> &lt;&lt; std::endl;<BR>
<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>const</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> angle = 10.0 * vcl_atan( 1.0f ) / 45.0; <BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>const</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> sinth = vcl_sin( angle );<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>const</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> costh = vcl_cos( angle );<BR>
&nbsp;<BR>
std::cout &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Testing Rotation:"</FONT></FONT><FONT size=2>;<BR>
eulerTransform-&gt;SetRotation(angle);<BR>
<BR>
EulerTransformType::InputPointType::ValueType pInit[2] = {10,10};<BR>
EulerTransformType::InputPointType p = pInit;<BR>
EulerTransformType::InputPointType q;<BR>
q[0] = p[0] * costh - p[1] * sinth;<BR>
q[1] = p[0] * sinth + p[1] * costh;<BR>
EulerTransformType::OutputPointType r;<BR>
r = eulerTransform-&gt;TransformPoint( p );<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>for</FONT></FONT><FONT size=2>(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>unsigned</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2> i=0; i&lt;N; i++)<BR>
{<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>( vcl_fabs( q[i]- r[i] ) &gt; epsilon )<BR>
{<BR>
Ok = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>false</FONT></FONT><FONT size=2>;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>break</FONT></FONT><FONT size=2>; <BR>
}<BR>
}<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2>( !Ok )<BR>
{ <BR>
std::cerr &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Error rotating point : "</FONT></FONT><FONT size=2> &lt;&lt; p &lt;&lt; std::endl;<BR>
std::cerr &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Result should be : "</FONT></FONT><FONT size=2> &lt;&lt; q &lt;&lt; std::endl;<BR>
std::cerr &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"Reported Result is : "</FONT></FONT><FONT size=2> &lt;&lt; r &lt;&lt; std::endl;<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> EXIT_FAILURE;<BR>
}<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>else<BR></FONT></FONT><FONT size=2>
{<BR>
std::cout &lt;&lt; </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" [ PASSED ] "</FONT></FONT><FONT size=2> &lt;&lt; std::endl;<BR>
}<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>
Thank you!<BR></FONT>
&nbsp;<BR>                                               </body>
</html>