9 template <
class TScalarType>
14 m_Angles.Fill(itk::NumericTraits<TScalarType>::Zero);
15 m_LogVector.Fill(itk::NumericTraits<TScalarType>::Zero);
16 m_LogTransform.set_size(4,4);
18 this->ComputeMatrix();
22 template <
class TScalarType>
27 itkDebugMacro( <<
"Setting parameters " << parameters );
29 m_Angles[0] = parameters[0];
30 m_Angles[1] = parameters[1];
31 m_Angles[2] = parameters[2];
34 newTranslation[0] = parameters[3];
35 newTranslation[1] = parameters[4];
36 newTranslation[2] = parameters[5];
38 this->SetTranslation(newTranslation);
40 this->ComputeMatrix();
46 itkDebugMacro(<<
"After setting parameters ");
51 template <
class TScalarType>
56 this->m_Parameters[0] = m_Angles[0];
57 this->m_Parameters[1] = m_Angles[1];
58 this->m_Parameters[2] = m_Angles[2];
60 this->m_Parameters[3] = this->GetTranslation()[0];
61 this->m_Parameters[4] = this->GetTranslation()[1];
62 this->m_Parameters[5] = this->GetTranslation()[2];
64 return this->m_Parameters;
68 template <
class TScalarType>
73 Superclass::SetIdentity();
74 m_Angles.Fill(itk::NumericTraits<TScalarType>::Zero);
76 this->ComputeMatrix();
80 template <
class TScalarType>
85 this->ComputeLogRepresentations();
87 vnl_matrix <TScalarType> transformMatrix =
GetExponential(m_LogTransform);
92 for (
unsigned int i = 0;i < 3;++i)
94 off[i] = transformMatrix(i,3);
95 for (
unsigned int j = 0;j < 3;++j)
96 linearMatrix(i,j) = transformMatrix(i,j);
99 this->SetMatrix(linearMatrix);
100 this->SetOffset(off);
103 template <
class TScalarType>
108 m_LogVector.Fill(itk::NumericTraits<TScalarType>::Zero);
110 for (
unsigned int i = 0;i < 3;++i)
111 m_LogVector[i] = m_Angles[i];
113 m_LogTransform.fill(itk::NumericTraits<TScalarType>::Zero);
115 unsigned int pos = 0;
116 for (
unsigned int i = 0;i < 3;++i)
118 for (
unsigned int j = i+1;j < 3;++j)
120 m_LogTransform(i,j) = m_Angles[pos];
121 m_LogTransform(j,i) = - m_Angles[pos];
126 for (
unsigned int i = 0;i < 3;++i)
128 m_LogVector[i+3] = this->GetTranslation()[i];
129 for (
unsigned int j = 0;j < 3;++j)
130 m_LogVector[i+3] -= m_LogTransform(i,j) * this->GetCenter()[j];
133 for (
unsigned int i = 0;i < 3;++i)
134 m_LogTransform(i,3) = m_LogVector[i+3];
138 template<
class TScalarType>
143 Superclass::PrintSelf(os,indent);
145 os << indent <<
"Log-transform parameters: Angles=" << m_Angles << std::endl;
vnl_matrix< T > GetExponential(const vnl_matrix< T > &m, const int numApprox=1)
Computation of the matrix exponential. Algo: classical scaling and squaring, as in Matlab...