[Insight-users] Comparing AffineTransform and CenteredAffineTransform

Gavin Baker gavinb+xtk at cs . mu . OZ . AU
Thu, 16 Oct 2003 11:39:27 +1000


Hello Luis,

On Tue, Oct 14, 2003 at 10:55:45AM -0400, Luis Ibanez wrote:

> Thanks for posting your detailed code.
> 
> Your usage of the CenteredAffineTransform is correct.
> 
> The only detail missing is that after you have set the
> center and the rotation, the method "ComputeOffset()"
> must be called before using the transform.

Aha! I see... that makes sense now, looking at the code - but it is
certainly not obvious.

> The code will look like:
> 
> > caffine->SetCenter( centerB  );
> > caffine->Rotate( 0, 1, angle );
> > caffine->ComputeOffset();

I tested this and it does indeed work as expected.

> This is a bit missleading here...
> we should probably add a comment on the
> doxygen documentation.
> 
> 
> The CenteredAffineTransform derives from the
> AffineTransform. The offset of the base class
> should be recomputed in order to take into
> account the center of rotation.

Thanks for clearing this up.

Regards,

 :: Gavin

PS: Here is a little patch for the doc comments to cover this:


--- Code/Common/itkCenteredAffineTransform.h    2003-09-11 00:29:03.000000000 +1000
+++ /tmp/itkCenteredAffineTransform.h   2003-10-16 11:00:31.000000000 +1000
@@ -27,8 +27,11 @@
 /**
  * \brief Affine transformation with a specified center of rotation.
  *
- * This class implements an Affine transform in which the rotation center can be explicitly selected.
+ * This class implements an Affine transform in which the rotation center
+ * can be explicitly selected.
  *
+ * Note that once all the transformations (translation, rotation, etc) have
+ * been applied, ComputeOffset() must be called to recalculate the new offset.
  * 
  * \ingroup Transforms
  *
@@ -120,7 +123,8 @@
   itkGetConstReferenceMacro( Translation, OutputVectorType );
  
   /** Compute the offset using the rotation center, the matrix
-   *  and the final translation. */
+   *  and the final translation. This must be called after all
+   *  transformations have been applied. */
   virtual void ComputeOffset(void);
 
 protected:



-- 
Gavin Baker                                Computer Vision Lab (CVMIL)
http://www . cs . mu . oz . au/~gavinb                 University of Melbourne