17 #ifndef __itkCenteredSimilarity2DTransform_txx
18 #define __itkCenteredSimilarity2DTransform_txx
27 template <
class TScalarType>
36 template<
class TScalarType>
39 unsigned int parametersDimension):
47 template <
class TScalarType>
52 itkDebugMacro( <<
"Setting parameters " << parameters );
55 const TScalarType scale = parameters[0];
56 this->SetVarScale( scale );
59 const TScalarType angle = parameters[1];
60 this->SetVarAngle( angle );
63 for(
unsigned int j=0; j < SpaceDimension; j++)
65 center[j] = parameters[j+2];
67 this->SetVarCenter( center );
72 for(
unsigned int i=0; i < SpaceDimension; i++)
74 translation[i] = parameters[i+4];
77 this->SetVarTranslation( translation );
79 this->ComputeMatrix();
80 this->ComputeOffset();
86 itkDebugMacro(<<
"After setting parameters ");
91 template <
class TScalarType>
96 itkDebugMacro( <<
"Getting parameters ");
98 this->m_Parameters[0] = this->GetScale();
99 this->m_Parameters[1] = this->GetAngle();
102 for(
unsigned int j=0; j < SpaceDimension; j++)
104 this->m_Parameters[j+2] = center[j];
107 OffsetType translation = this->GetTranslation();
108 for(
unsigned int i=0; i < SpaceDimension; i++)
110 this->m_Parameters[i+4] = translation[i];
113 itkDebugMacro(<<
"After getting parameters " << this->m_Parameters );
115 return this->m_Parameters;
119 template<
class TScalarType>
124 const double angle = this->GetAngle();
125 const double ca = vcl_cos(angle );
126 const double sa = vcl_sin(angle );
128 this->m_Jacobian.Fill(0.0);
131 const double cx = center[0];
132 const double cy = center[1];
137 this->m_Jacobian[0][0] = ca * ( p[0] - cx ) - sa * ( p[1] - cy );
138 this->m_Jacobian[1][0] = sa * ( p[0] - cx ) + ca * ( p[1] - cy );
141 this->m_Jacobian[0][1] = ( -sa * ( p[0] - cx ) - ca * ( p[1] - cy ) )
143 this->m_Jacobian[1][1] = ( ca * ( p[0] - cx ) - sa * ( p[1] - cy ) )
148 this->m_Jacobian[0][2] = 1.0 - ca * this->GetScale();
149 this->m_Jacobian[1][2] = - sa * this->GetScale();
151 this->m_Jacobian[0][3] = sa * this->GetScale();
152 this->m_Jacobian[1][3] = 1.0 - ca * this->GetScale();
156 this->m_Jacobian[0][4] = 1.0;
157 this->m_Jacobian[1][4] = 0.0;
159 this->m_Jacobian[0][5] = 0.0;
160 this->m_Jacobian[1][5] = 1.0;
162 return this->m_Jacobian;
166 template <
class TScalarType>
174 template <
class TScalarType>
180 this->m_FixedParameters.SetSize(0);
181 return this->m_FixedParameters;
185 template<
class TScalarType>
190 Superclass::PrintSelf(os,indent);
194 template<
class TScalarType>
204 template<
class TScalarType>
215 inverse->
SetScale( NumericTraits<double>::One / this->GetScale() );
216 inverse->
SetAngle( -this->GetAngle() );
217 inverse->
SetTranslation( -( this->GetInverseMatrix() * this->GetTranslation() ) );
222 template<
class TScalarType>
228 if( this->GetInverse(inv) )
236 template<
class TScalarType>
242 result->SetCenter( this->GetCenter() );
243 result->SetScale( this->GetScale() );
244 result->SetAngle( this->GetAngle() );
245 result->SetTranslation( this->GetTranslation() );