/vol/vipdata/irtk/packages/transformation/include/irtkHomogeneousTransformation.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkHomogeneousTransformation.h 2 2008-12-23 12:40:14Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2008-12-23 12:40:14 +0000 (Tue, 23 Dec 2008) $
00008   Version   : $Revision: 2 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _HOMOGENEOUSTRANSFORMATION_H
00014 
00015 #define _HOMOGENEOUSTRANSFORMATION_H
00016 
00028 typedef enum {TX, TY, TZ, RX, RY, RZ, SX, SY, SZ, SXY, SYZ, SXZ, SYX, SZY, SZX}
00029 irtkHomogeneousTransformationParameterIndex;
00030 
00031 class irtkHomogeneousTransformation : public irtkTransformation
00032 {
00033 
00034 protected:
00035 
00037   irtkMatrix _matrix;
00038 
00039 public:
00040 
00042   irtkHomogeneousTransformation();
00043 
00045   irtkHomogeneousTransformation(const irtkMatrix &);
00046 
00048   irtkHomogeneousTransformation(const irtkHomogeneousTransformation &);
00049 
00051   virtual ~irtkHomogeneousTransformation();
00052 
00054   virtual int    NumberOfDOFs() const;
00055 
00057   virtual double Get(int) const;
00058 
00060   virtual void   Put(int, double);
00061 
00063   virtual irtkMatrix GetMatrix() const;
00064 
00066   virtual void      PutMatrix(const irtkMatrix &);
00067 
00069   virtual void Transform(double &, double &, double &, double = 0);
00070 
00072   virtual void GlobalTransform(double &, double &, double &, double = 0);
00073 
00075   virtual void LocalTransform (double &, double &, double &, double = 0);
00076 
00078   virtual void GlobalDisplacement(double &, double &, double &, double = 0);
00079 
00081   virtual void LocalDisplacement(double &, double &, double &, double = 0);
00082 
00084   virtual void Invert();
00085 
00087   virtual double Inverse(double &, double &, double &, double = 0, double = 0.01);
00088 
00090   virtual void Jacobian(irtkMatrix &, double, double, double, double = 0);
00091 
00093   virtual void LocalJacobian(irtkMatrix &, double, double, double, double = 0);
00094 
00096   virtual void GlobalJacobian(irtkMatrix &, double, double, double, double = 0);
00097 
00099   virtual Bool IsIdentity();
00100 
00102   virtual void Print();
00103 
00105   virtual const char *NameOfClass();
00106 
00108   virtual irtkCifstream& Read(irtkCifstream&);
00109 
00111   virtual irtkCofstream& Write(irtkCofstream&);
00112 
00114   virtual void Import(char *);
00115 
00117   virtual void Export(char *);
00118 
00120   virtual istream& Import(istream&);
00121 
00123   virtual ostream& Export(ostream&);
00124 
00125 };
00126 
00127 inline int irtkHomogeneousTransformation::NumberOfDOFs() const
00128 {
00129   return 12;
00130 }
00131 
00132 inline irtkHomogeneousTransformation::irtkHomogeneousTransformation()
00133 {
00134   int i;
00135 
00136   // Create 4 x 4 transformation matrix
00137   _matrix = irtkMatrix(4, 4);
00138 
00139   // Initialize to identity
00140   _matrix.Ident();
00141 
00142   // Allocate memory for DOF status
00143   _status = new _Status[this->NumberOfDOFs()];
00144 
00145   // Initialize memory for DOF status
00146   for (i = 0; i < this->NumberOfDOFs(); i++) {
00147     _status[i] = _Active;
00148   }
00149 }
00150 
00151 inline irtkHomogeneousTransformation::irtkHomogeneousTransformation(const irtkMatrix &matrix)
00152 {
00153   int i;
00154 
00155   _matrix = matrix;
00156 
00157   // Allocate memory for DOF status
00158   _status = new _Status[this->NumberOfDOFs()];
00159 
00160   // Initialize memory for DOF status
00161   for (i = 0; i < this->NumberOfDOFs(); i++) {
00162     _status[i] = _Active;
00163   }
00164 }
00165 
00166 inline irtkHomogeneousTransformation::irtkHomogeneousTransformation(const irtkHomogeneousTransformation &t)
00167 {
00168   int i;
00169 
00170   _matrix = t._matrix;
00171 
00172   // Allocate memory for DOF status
00173   _status = new _Status[this->NumberOfDOFs()];
00174 
00175   // Initialize memory for DOF status
00176   for (i = 0; i < this->NumberOfDOFs(); i++) {
00177     _status[i] = t._status[i];
00178   }
00179 }
00180 
00181 inline irtkHomogeneousTransformation::~irtkHomogeneousTransformation()
00182 {
00183 }
00184 
00185 inline void irtkHomogeneousTransformation::PutMatrix(const irtkMatrix &matrix)
00186 {
00187   _matrix = matrix;
00188 }
00189 
00190 inline irtkMatrix irtkHomogeneousTransformation::GetMatrix() const
00191 {
00192   return _matrix;
00193 }
00194 
00195 inline void irtkHomogeneousTransformation::GlobalTransform(double &x, double &y, double &z, double t)
00196 {
00197   this->Transform(x, y, z, t);
00198 }
00199 
00200 inline void irtkHomogeneousTransformation::LocalTransform(double &x, double &y, double &z, double)
00201 {
00202 }
00203 
00204 inline void irtkHomogeneousTransformation::GlobalDisplacement(double &x, double &y, double &z, double t)
00205 {
00206   double a, b, c;
00207 
00208   a = x;
00209   b = y;
00210   c = z;
00211   this->Transform(a, b, c, t);
00212   x = a - x;
00213   y = b - y;
00214   z = c - z;
00215 }
00216 
00217 inline void irtkHomogeneousTransformation::LocalDisplacement(double &x, double &y, double &z, double)
00218 {
00219   x = 0;
00220   y = 0;
00221   z = 0;
00222 }
00223 
00224 inline const char *irtkHomogeneousTransformation::NameOfClass()
00225 {
00226   return "irtkHomogeneousTransformation";
00227 }
00228 
00229 #endif