OTB  6.7.0
Orfeo Toolbox
otbLogPolarTransform.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbLogPolarTransform_hxx
22 #define otbLogPolarTransform_hxx
23 
24 #include "otbLogPolarTransform.h"
25 #include "otbMacro.h"
26 #include "otbMath.h"
27 
28 namespace otb
29 {
33 template <class TScalarType>
36  : Superclass(4)
37 {
38  m_Center[0] = 0.0;
39  m_Center[1] = 0.0;
40  m_Scale[0] = 1.0;
41  m_Scale[1] = 1.0;
42 }
43 
47 template <class TScalarType>
50 {}
51 
56 template <class TScalarType>
57 void
59 ::SetParameters(const ParametersType& parameters)
60 {
61  m_Center[0] = parameters[0];
62  m_Center[1] = parameters[1];
63  m_Scale[0] = parameters[2];
64  m_Scale[1] = parameters[3];
65  otbMsgDebugMacro(<< "Call To SetParameters: Center=" << m_Center << ", Scale=" << m_Scale);
66  this->m_Parameters = parameters;
67  this->Modified();
68 }
69 
74 template <class TScalarType>
78 ::GetParameters(void) const
79 {
80  // Filling parameters vector
81  this->m_Parameters[0] = m_Center[0];
82  this->m_Parameters[1] = m_Center[1];
83  this->m_Parameters[2] = m_Scale[0];
84  this->m_Parameters[3] = m_Scale[1];
85 
86  return this->m_Parameters;
87 }
93 template <class TScalarType>
95 ::OutputPointType
97 ::TransformPoint(const InputPointType& point) const
98 {
99  OutputPointType result;
100  double theta = point[0] * m_Scale[0] * CONST_PI_180;
101  double logRho = point[1] * m_Scale[1];
102  result[0] = m_Center[0];
103  result[1] = m_Center[1];
104  result[0] += std::exp(logRho) * std::cos(theta);
105  result[1] += std::exp(logRho) * std::sin(theta);
106  return result;
107 }
108 
114 template <class TScalarType>
116 ::OutputVectorType
118 ::TransformVector(const InputVectorType& vector) const
119 {
120  OutputVectorType result;
121  double theta = vector[0] * m_Scale[0] * CONST_PI_180;
122  double logRho = vector[1] * m_Scale[1];
123  result[0] = 0.;
124  result[1] = 0.;
125  result[0] += std::exp(logRho) * std::cos(theta);
126  result[1] += std::exp(logRho) * std::sin(theta);
128 
129  return result;
130 }
136 template <class TScalarType>
138 ::OutputVnlVectorType
141 {
142  OutputVnlVectorType result;
143  double theta = vector[0] * m_Scale[0] * CONST_PI_180;
144  double logRho = vector[1] * m_Scale[1];
145  result[0] = 0.;
146  result[1] = 0.;
147  result[0] += std::exp(logRho) * std::cos(theta);
148  result[1] += std::exp(logRho) * std::sin(theta);
150 
151  return result;
152 }
156 template <class TScalarType>
157 void
159 ::PrintSelf(std::ostream& os, itk::Indent indent) const
160 {
161  Superclass::PrintSelf(os, indent);
162  os << indent << "Center: " << m_Center << std::endl;
163  os << indent << "Scale: " << m_Scale << std::endl;
164 }
166 
167 } // end namespace otb
168 #endif
void SetParameters(const ParametersType &parameters) override
Superclass::InputPointType InputPointType
#define otbMsgDebugMacro(x)
Definition: otbMacro.h:64
Superclass::OutputVnlVectorType OutputVnlVectorType
constexpr double CONST_PI_180
Definition: otbMath.h:55
Superclass::InputVnlVectorType InputVnlVectorType
itk::Array< double > ParametersType
Definition: mvdTypes.h:122
OutputPointType TransformPoint(const InputPointType &point) const override
ParametersType & GetParameters(void) const override
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Implement the log-polar coordinate transform.
Superclass::InputVectorType InputVectorType
OutputVectorType TransformVector(const InputVectorType &vector) const override