21 #ifndef otbRationalTransform_h
22 #define otbRationalTransform_h
50 template <
class TScalarType =
double,
unsigned int Dimension = 2>
79 itkStaticConstMacro(SpaceDimension,
unsigned int, Dimension);
84 this->m_NumeratorDegree = value;
85 this->InitializeParameters();
90 itkGetConstMacro(NumeratorDegree,
unsigned int);
95 this->m_DenominatorDegree = value;
96 this->InitializeParameters();
101 itkGetConstMacro(DenominatorDegree,
unsigned int);
107 if (this->GetNumberOfParameters() != this->m_Parameters.size())
110 itkExceptionMacro(<<
"Wrong number of parameters: found " << this->m_Parameters.Size() <<
", expected " << this->GetNumberOfParameters());
118 unsigned int dimensionStride = (m_DenominatorDegree + 1) + (m_NumeratorDegree + 1);
121 for (
unsigned int dim = 0; dim < SpaceDimension; ++dim)
124 TScalarType num = itk::NumericTraits<TScalarType>::Zero;
125 TScalarType denom = itk::NumericTraits<TScalarType>::Zero;
126 TScalarType currentPower = 1.;
129 for (
unsigned int numDegree = 0; numDegree <= m_NumeratorDegree; ++numDegree)
131 num += this->m_Parameters[dim * dimensionStride + numDegree] * currentPower;
132 currentPower *= inputPoint[dim];
137 for (
unsigned int denomDegree = 0; denomDegree <= m_DenominatorDegree; ++denomDegree)
139 denom += this->m_Parameters[dim * dimensionStride + m_NumeratorDegree + denomDegree + 1] * currentPower;
140 currentPower *= inputPoint[dim];
144 outputPoint[dim] = num / denom;
154 return (
static_cast<NumberOfParametersType>((m_NumeratorDegree + 1 + m_DenominatorDegree + 1) * SpaceDimension));
161 if (params.Size() != this->GetNumberOfParameters())
163 itkExceptionMacro(<<
"Wrong number of parameters: found " << params.Size() <<
", expected " << this->GetNumberOfParameters());
167 this->m_Parameters = params;
173 this->m_Parameters.SetSize(this->GetNumberOfParameters());
174 this->m_Parameters.Fill(0);
175 unsigned int dimensionStride = (m_DenominatorDegree + 1) + (m_NumeratorDegree + 1);
178 for (
unsigned int dim = 0; dim < SpaceDimension; ++dim)
180 this->m_Parameters[dimensionStride * dim + m_NumeratorDegree + 1] = 1.;
188 this->InitializeParameters();
196 void PrintSelf(std::ostream& os, itk::Indent indent)
const override
198 Superclass::PrintSelf(os, indent);
199 os << indent <<
"Numerator Degree : " << m_NumeratorDegree << std::endl;
200 os << indent <<
"Denominator Degree : " << m_DenominatorDegree << std::endl;
205 void operator=(
const Self&) =
delete;