[Insight-developers] Bug in CenteredRigid2DTransform

Miller, James V (Research) millerjv@crd.ge.com
Fri, 24 Jan 2003 10:13:12 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2C3BB.1CCD79CC
Content-Type: text/plain;
	charset="iso-8859-1"

I am having trouble using the CenteredRigid2DTransform and I think there is a bug in the
ComputeMatrixAndOffset() method.  This transform allows to specify a center of rotation and angle to
rotate about and an amount to translate after rotation.
 
For my task at hand, I just want to rotate an image about its center. So I specify the center and
translation as the same point.  This should translate the center of the image to the origin, rotate
by the specified angle and translate the center back to the original position.
 
The code to compute the offset (final composed translation component of the transform) is currently

  offset[0] = tx + sa * cy + ( 1.0 - ca ) * cx;
  offset[1] = ty - sa * cx + ( 1.0 - ca ) * cy;

where ca, sa are the sine and cosine of the angle, cx and cy are the center to rotate about, and tx
and ty are the final translation.
 
I think this code should be 
 
  offset[0] = tx - ca * cx + sa * cy;
  offset[1] = ty - sa * cx - ca * cy;

note the signs are set such that we translate the origin to the center (shift by negative center),
rotate, then translate to the specified position.
 
Does this make sense?




<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 

Jim Miller 
_____________________________________
Visualization & Computer Vision
GE Research
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301

millerjv@research.ge.com <mailto:millerjv@research.ge.com> 

james.miller@research.ge.com
(518) 387-4005, Dial Comm: 8*833-4005, 
Cell: (518) 505-7065, Fax: (518) 387-6981 

 

 

------_=_NextPart_001_01C2C3BB.1CCD79CC
Content-Type: text/html;
	charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">


<META content="MSHTML 6.00.2715.400" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=041260615-24012003><FONT size=2>I am having trouble using the 
CenteredRigid2DTransform and I think there is a bug in the 
ComputeMatrixAndOffset() method.&nbsp; This transform allows to specify a center 
of rotation and angle to rotate about and an amount to translate after 
rotation.</FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>For my task at hand, I just 
want to rotate an image about its center. So I specify the center and 
translation as the same point.&nbsp; This should translate the center of the 
image to the origin, rotate by the specified angle and translate the center back 
to the original position.</FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>The code to compute the offset 
(final composed translation component of the transform) is 
currently</FONT></SPAN></DIV>
<DIV class=Section1>
<P class=MsoNormal>&nbsp;<FONT size=2>&nbsp;offset[0] = tx + sa * cy + ( 1.0 - 
ca ) * cx;<BR>&nbsp; offset[1] = ty - sa * cx + ( 1.0 - ca ) * 
cy;</FONT></P><FONT size=2></FONT></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>where ca, sa are the sine and 
cosine of the angle, cx and cy are the center to rotate about, and tx and ty are 
the final translation.</FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>I think this code should be 
</FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>&nbsp; offset[0] = tx - ca * cx 
+ sa * cy;<BR>&nbsp; offset[1] = ty - sa * cx - ca * cy;<BR></FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>note the signs are set such 
that we translate the origin to the center (shift by negative center), rotate, 
then translate to the specified position.</FONT></SPAN></DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=041260615-24012003><FONT size=2>Does this make 
sense?</DIV></FONT></SPAN>
<P class=MsoNormal><FONT size=2><BR></FONT></P><?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<P class=Section1 style="MARGIN: 0in 0in 0pt"><B><SPAN 
style="COLOR: navy; FONT-FAMILY: 'Comic Sans MS'">Jim Miller</SPAN></B> 
<BR><B><I><SPAN 
style="FONT-SIZE: 10pt; COLOR: red; FONT-FAMILY: Arial">_____________________________________</SPAN></I></B><BR><EM><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Visualization &amp; 
Computer Vision</SPAN></EM><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial"><BR><EM>GE 
Research</EM><BR><EM>Bldg. KW, Room C218B</EM><BR><EM>P.O. Box 8, Schenectady NY 
12301</EM><BR><BR></SPAN></I><EM><U><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: blue"><A 
href="mailto:millerjv@research.ge.com">millerjv@research.ge.com</A></SPAN></U></EM></P>
<P class=Section1 style="MARGIN: 0in 0in 0pt"><EM><U><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: blue">james.miller@research.ge.com</SPAN></U></EM><BR><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">(518) 387-4005, Dial 
Comm: 8*833-4005, </SPAN></I><BR><I><SPAN 
style="FONT-SIZE: 7.5pt; COLOR: black; FONT-FAMILY: Arial">Cell: (518) 505-7065, 
Fax: (518) 387-6981</SPAN></I> </P>
<P class=MsoNormal>&nbsp;<o:p></o:p></P>
<DIV>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C2C3BB.1CCD79CC--