/vol/vipdata/irtk/packages/transformation/include/irtkHomogeneousTransformationIterator.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _IRTKHOMOGENEOUSTRANSFORMATION_ITERATOR_H
00014
00015 #define _IRTKHOMOGENEOUSTRANSFORMATION_ITERATOR_H
00016
00026 class irtkHomogeneousTransformationIterator : public irtkPoint
00027 {
00028
00030 irtkHomogeneousTransformation *_transformation;
00031
00032 public:
00033
00035 double _xx, _xy, _xz;
00036
00038 double _yx, _yy, _yz;
00039
00041 double _zx, _zy, _zz;
00042
00044 double _xdx, _xdy, _xdz;
00045
00047 double _ydx, _ydy, _ydz;
00048
00050 double _zdx, _zdy, _zdz;
00051
00053 irtkHomogeneousTransformationIterator(irtkHomogeneousTransformation * = NULL);
00054
00057 void Initialize(irtkBaseImage *target, irtkBaseImage *source, double x = 0, double y = 0, double z = 0);
00058
00060 void NextX();
00061
00063 void NextX(double);
00064
00066 void NextY();
00067
00069 void NextY(double);
00070
00072 void NextZ();
00073
00075 void NextZ(double);
00076
00078 void SetTransformation(irtkHomogeneousTransformation* pTransformation);
00079 };
00080
00081 inline irtkHomogeneousTransformationIterator::irtkHomogeneousTransformationIterator(irtkHomogeneousTransformation *transformation)
00082 {
00083 _transformation = transformation;
00084 }
00085
00086 inline void irtkHomogeneousTransformationIterator::Initialize(irtkBaseImage *target, irtkBaseImage *source, double x, double y, double z)
00087 {
00088
00089 if (_transformation == NULL) {
00090 cout << "irtkHomogeneousTransformationIterator::Initialize(): Transformation has not been set." << endl;
00091 exit(1);
00092 }
00093
00094
00095 irtkMatrix matrix = source->GetWorldToImageMatrix() * _transformation->GetMatrix() * target->GetImageToWorldMatrix();
00096
00097 _x = matrix(0, 0) * x + matrix(0, 1) * y + matrix(0, 2) * z + matrix(0, 3);
00098 _y = matrix(1, 0) * x + matrix(1, 1) * y + matrix(1, 2) * z + matrix(1, 3);
00099 _z = matrix(2, 0) * x + matrix(2, 1) * y + matrix(2, 2) * z + matrix(2, 3);
00100
00101
00102 _xx = _yx = _zx = _x;
00103 _xy = _yy = _zy = _y;
00104 _xz = _yz = _zz = _z;
00105
00106
00107 _zdx = matrix(0, 2);
00108 _zdy = matrix(1, 2);
00109 _zdz = matrix(2, 2);
00110 _ydx = matrix(0, 1);
00111 _ydy = matrix(1, 1);
00112 _ydz = matrix(2, 1);
00113 _xdx = matrix(0, 0);
00114 _xdy = matrix(1, 0);
00115 _xdz = matrix(2, 0);
00116 }
00117
00118 inline void irtkHomogeneousTransformationIterator::SetTransformation(irtkHomogeneousTransformation* transformation)
00119 {
00120 _transformation = transformation;
00121 }
00122
00123 inline void irtkHomogeneousTransformationIterator::NextX()
00124 {
00125 _x = _xx += _xdx;
00126 _y = _xy += _xdy;
00127 _z = _xz += _xdz;
00128 }
00129
00130 inline void irtkHomogeneousTransformationIterator::NextX(double offset)
00131 {
00132 _x = _xx += _xdx * offset;
00133 _y = _xy += _xdy * offset;
00134 _z = _xz += _xdz * offset;
00135 }
00136
00137 inline void irtkHomogeneousTransformationIterator::NextY()
00138 {
00139 _yx += _ydx;
00140 _yy += _ydy;
00141 _yz += _ydz;
00142 _x = _xx = _yx;
00143 _y = _xy = _yy;
00144 _z = _xz = _yz;
00145 }
00146
00147 inline void irtkHomogeneousTransformationIterator::NextY(double offset)
00148 {
00149 _yx += _ydx * offset;
00150 _yy += _ydy * offset;
00151 _yz += _ydz * offset;
00152 _x = _xx = _yx;
00153 _y = _xy = _yy;
00154 _z = _xz = _yz;
00155 }
00156
00157 inline void irtkHomogeneousTransformationIterator::NextZ()
00158 {
00159 _zx += _zdx;
00160 _zy += _zdy;
00161 _zz += _zdz;
00162 _x = _xx = _yx = _zx;
00163 _y = _xy = _yy = _zy;
00164 _z = _xz = _yz = _zz;
00165 }
00166
00167 inline void irtkHomogeneousTransformationIterator::NextZ(double offset)
00168 {
00169 _zx += _zdx * offset;
00170 _zy += _zdy * offset;
00171 _zz += _zdz * offset;
00172 _x = _xx = _yx = _zx;
00173 _y = _xy = _yy = _zy;
00174 _z = _xz = _yz = _zz;
00175 }
00176
00177 #endif