OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ossimAffineTransform Class Reference

#include <ossimAffineTransform.h>

Inheritance diagram for ossimAffineTransform:
ossim2dTo2dTransform ossimObject ossimReferenced

Public Member Functions

 ossimAffineTransform ()
 
 ossimAffineTransform (const ossimAffineTransform &src)
 
virtual const ossimAffineTransformoperator= (const ossimAffineTransform &rhs)
 assignment operator= More...
 
virtual ossimObjectdup () const
 
virtual void forward (const ossimDpt &input, ossimDpt &output) const
 
virtual void inverse (const ossimDpt &input, ossimDpt &output) const
 
virtual ossimDpt getOrigin () const
 
bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
void setMatrix (double rotation, const ossimDpt &scale, const ossimDpt &translation)
 
void setScale (const ossimDpt &scale)
 
void setRotation (double rotation)
 
void setTranslation (const ossimDpt &translation)
 
ossimDpt getScale () const
 
ossimDpt getTranslation () const
 
double getRotation () const
 
void setIdentity ()
 
void setAffineEnabledFlag (bool flag)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
- Public Member Functions inherited from ossim2dTo2dTransform
virtual void forward (ossimDpt &modify_this) const
 
virtual void inverse (ossimDpt &modify_this) const
 
virtual const ossim2dTo2dTransformoperator= (const ossim2dTo2dTransform &rhs)
 
void setConvergenceThreshold (const double &new_threshold)
 
void setMaxIterations (int new_max_iters)
 
void setDxDy (const ossimDpt &dxdy)
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual ossimString getClassName () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Protected Member Functions

void computeMatrix ()
 
- Protected Member Functions inherited from ossim2dTo2dTransform
 ossim2dTo2dTransform ()
 
virtual ~ossim2dTo2dTransform ()
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimDpt theScale
 
double theRotation
 
ossimDpt theTranslation
 
bool theAffineEnabledFlag
 
NEWMAT::Matrix theForwardXform
 
NEWMAT::Matrix theInverseXform
 
- Protected Attributes inherited from ossim2dTo2dTransform
double theConvergenceThreshold
 
int theMaxIterations
 
ossimDpt theDxDy
 

Detailed Description

Definition at line 16 of file ossimAffineTransform.h.

Constructor & Destructor Documentation

◆ ossimAffineTransform() [1/2]

ossimAffineTransform::ossimAffineTransform ( )

Definition at line 25 of file ossimAffineTransform.cpp.

References setIdentity().

◆ ossimAffineTransform() [2/2]

ossimAffineTransform::ossimAffineTransform ( const ossimAffineTransform src)

Member Function Documentation

◆ computeMatrix()

void ossimAffineTransform::computeMatrix ( )
protected

Definition at line 210 of file ossimAffineTransform.cpp.

References ossimMatrix3x3::createRotationZMatrix(), ossimMatrix3x3::createScaleMatrix(), ossimMatrix3x3::createTranslationMatrix(), theForwardXform, theInverseXform, theRotation, theScale, theTranslation, ossimDpt::x, and ossimDpt::y.

Referenced by loadState(), setIdentity(), and setMatrix().

211 {
214  theTranslation.y)*
217  theScale.y,
218  1.0);
219 
220  //***
221  // The inverse transform is just the matrix inverse:
222  //***
224 }
double y
Definition: ossimDpt.h:165
NEWMAT::Matrix theInverseXform
NEWMAT::Matrix theForwardXform
static NEWMAT::Matrix createTranslationMatrix(double dx, double dy)
static NEWMAT::Matrix createRotationZMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
double x
Definition: ossimDpt.h:164
static NEWMAT::Matrix createScaleMatrix(double X, double Y, double Z)

◆ dup()

virtual ossimObject* ossimAffineTransform::dup ( ) const
inlinevirtual

Reimplemented from ossimObject.

Definition at line 30 of file ossimAffineTransform.h.

31  {
32  return new ossimAffineTransform(*this);
33  }

◆ forward()

void ossimAffineTransform::forward ( const ossimDpt input,
ossimDpt output 
) const
virtual

Implements ossim2dTo2dTransform.

Definition at line 70 of file ossimAffineTransform.cpp.

References theAffineEnabledFlag, theForwardXform, ossimDpt::x, and ossimDpt::y.

72 {
74  {
75  output.x = theForwardXform[0][0]*input.x+
76  theForwardXform[0][1]*input.y+
77  theForwardXform[0][2];
78  output.y = theForwardXform[1][0]*input.x+
79  theForwardXform[1][1]*input.y+
80  theForwardXform[1][2];
81  }
82  else
83  {
84  output = input;
85  }
86 }
double y
Definition: ossimDpt.h:165
NEWMAT::Matrix theForwardXform
double x
Definition: ossimDpt.h:164

◆ getOrigin()

virtual ossimDpt ossimAffineTransform::getOrigin ( ) const
inlinevirtual

Used by the inverse iterator. This will give it a good initial value that is within the input transforms

Reimplemented from ossim2dTo2dTransform.

Definition at line 43 of file ossimAffineTransform.h.

44  {
45  return ossimDpt(0,0);
46  }

◆ getRotation()

double ossimAffineTransform::getRotation ( ) const
inline

Definition at line 83 of file ossimAffineTransform.h.

84  {
85  return theRotation;
86  }

◆ getScale()

ossimDpt ossimAffineTransform::getScale ( ) const
inline

Definition at line 75 of file ossimAffineTransform.h.

76  {
77  return theScale;
78  }

◆ getTranslation()

ossimDpt ossimAffineTransform::getTranslation ( ) const
inline

Definition at line 79 of file ossimAffineTransform.h.

80  {
81  return theTranslation;
82  }

◆ inverse()

void ossimAffineTransform::inverse ( const ossimDpt input,
ossimDpt output 
) const
virtual

Reimplemented from ossim2dTo2dTransform.

Definition at line 91 of file ossimAffineTransform.cpp.

References theAffineEnabledFlag, theInverseXform, ossimDpt::x, and ossimDpt::y.

93 {
95  {
96  output.x = theInverseXform[0][0]*input.x+
97  theInverseXform[0][1]*input.y+
98  theInverseXform[0][2];
99  output.y = theInverseXform[1][0]*input.x+
100  theInverseXform[1][1]*input.y+
101  theInverseXform[1][2];
102  }
103  else
104  {
105  output = input;
106  }
107 }
double y
Definition: ossimDpt.h:165
NEWMAT::Matrix theInverseXform
double x
Definition: ossimDpt.h:164

◆ loadState()

bool ossimAffineTransform::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Method to the load (recreate) the state of the object from a keyword list. Return true if ok or false on error.

Reimplemented from ossim2dTo2dTransform.

Definition at line 144 of file ossimAffineTransform.cpp.

References computeMatrix(), ossimKeywordlist::find(), ossim2dTo2dTransform::loadState(), ossimKeywordNames::ROTATION_KW, ossimKeywordNames::SCALE_X_KW, ossimKeywordNames::SCALE_Y_KW, theRotation, theScale, theTranslation, ossimKeywordNames::TRANSLATION_X_KW, ossimKeywordNames::TRANSLATION_Y_KW, ossimDpt::x, and ossimDpt::y.

146 {
147  const char* buf;
148 
149  if (!ossim2dTo2dTransform::loadState(kwl, prefix))
150  goto BAD_KEYWORD;
151 
152  buf= kwl.find(prefix, ossimKeywordNames::SCALE_X_KW);
153  if (!buf) goto BAD_KEYWORD;
154  theScale.x = std::atof(buf);
155 
156  buf= kwl.find(prefix, ossimKeywordNames::SCALE_Y_KW);
157  if (!buf) goto BAD_KEYWORD;
158  theScale.y = std::atof(buf);
159 
160  buf= kwl.find(prefix, ossimKeywordNames::TRANSLATION_X_KW);
161  if (!buf) goto BAD_KEYWORD;
162  theTranslation.x = std::atof(buf);
163 
164  buf= kwl.find(prefix, ossimKeywordNames::TRANSLATION_Y_KW);
165  if (!buf) goto BAD_KEYWORD;
166  theTranslation.y = std::atof(buf);
167 
168  buf= kwl.find(prefix, ossimKeywordNames::ROTATION_KW);
169  if (!buf) goto BAD_KEYWORD;
170  theRotation = std::atof(buf);
171 
172  computeMatrix();
173  return true;
174 
175  BAD_KEYWORD:
176  return false;
177 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
const char * find(const char *key) const
double y
Definition: ossimDpt.h:165
static const char * SCALE_X_KW
static const char * ROTATION_KW
static const char * SCALE_Y_KW
static const char * TRANSLATION_X_KW
static const char * TRANSLATION_Y_KW
double x
Definition: ossimDpt.h:164

◆ operator=()

const ossimAffineTransform & ossimAffineTransform::operator= ( const ossimAffineTransform rhs)
virtual

assignment operator=

Parameters
rhsThe data to assign from.
Areference to this object.

Definition at line 50 of file ossimAffineTransform.cpp.

References ossim2dTo2dTransform::operator=(), theAffineEnabledFlag, theForwardXform, theInverseXform, theRotation, theScale, and theTranslation.

52 {
53  if (this != &rhs)
54  {
56 
57  theScale = rhs.theScale;
63  }
64  return *this;
65 }
virtual const ossim2dTo2dTransform & operator=(const ossim2dTo2dTransform &rhs)
NEWMAT::Matrix theInverseXform
NEWMAT::Matrix theForwardXform

◆ print()

std::ostream & ossimAffineTransform::print ( std::ostream &  out) const
virtual

Generic print method.

Derived classes should re-implement as they see fit.

Returns
std::ostream&

Reimplemented from ossim2dTo2dTransform.

Definition at line 230 of file ossimAffineTransform.cpp.

References theRotation, theScale, and theTranslation.

231 {
232  os << "ossimAffineTransform:"
233  << "\n theScale = " << theScale
234  << "\n theTranslation = " << theTranslation
235  << "\n theRotation = " << theRotation << std::endl;
236  return os;
237 }

◆ saveState()

bool ossimAffineTransform::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Method to save the state of the object to a keyword list. Return true if ok or false on error.

Reimplemented from ossim2dTo2dTransform.

Definition at line 112 of file ossimAffineTransform.cpp.

References ossimKeywordlist::add(), ossimKeywordNames::ROTATION_KW, ossim2dTo2dTransform::saveState(), ossimKeywordNames::SCALE_X_KW, ossimKeywordNames::SCALE_Y_KW, theRotation, theScale, theTranslation, ossimKeywordNames::TRANSLATION_X_KW, ossimKeywordNames::TRANSLATION_Y_KW, ossimDpt::x, and ossimDpt::y.

114 {
115  kwl.add(prefix,
117  theScale.x,
118  true);
119  kwl.add(prefix,
121  theScale.y,
122  true);
123  kwl.add(prefix,
126  true);
127  kwl.add(prefix,
130  true);
131  kwl.add(prefix,
133  theRotation,
134  true);
135 
136  ossim2dTo2dTransform::saveState(kwl, prefix);
137 
138  return true;
139 }
double y
Definition: ossimDpt.h:165
static const char * SCALE_X_KW
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
static const char * ROTATION_KW
static const char * SCALE_Y_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const char * TRANSLATION_X_KW
static const char * TRANSLATION_Y_KW
double x
Definition: ossimDpt.h:164

◆ setAffineEnabledFlag()

void ossimAffineTransform::setAffineEnabledFlag ( bool  flag)
inline

Definition at line 89 of file ossimAffineTransform.h.

90  {
91  theAffineEnabledFlag = flag;
92  }

◆ setIdentity()

void ossimAffineTransform::setIdentity ( )

Definition at line 196 of file ossimAffineTransform.cpp.

References computeMatrix(), theRotation, theScale, theTranslation, ossimDpt::x, and ossimDpt::y.

Referenced by ossimAffineTransform().

197 {
198  theScale.x = 1;
199  theScale.y = 1;
200  theTranslation.x = 0;
201  theTranslation.y = 0;
202  theRotation = 0.0;
203 
204  computeMatrix();
205 }
double y
Definition: ossimDpt.h:165
double x
Definition: ossimDpt.h:164

◆ setMatrix()

void ossimAffineTransform::setMatrix ( double  rotation,
const ossimDpt scale,
const ossimDpt translation 
)

Definition at line 182 of file ossimAffineTransform.cpp.

References computeMatrix(), theRotation, theScale, and theTranslation.

185 {
186  theScale = scale;
187  theRotation = rotation;
188  theTranslation = translation;
189 
190  computeMatrix();
191 }

◆ setRotation()

void ossimAffineTransform::setRotation ( double  rotation)
inline

Definition at line 64 of file ossimAffineTransform.h.

65  {
66  theRotation = rotation;
67  computeMatrix();
68  }

◆ setScale()

void ossimAffineTransform::setScale ( const ossimDpt scale)
inline

Definition at line 58 of file ossimAffineTransform.h.

59  {
60  theScale = scale;
61  computeMatrix();
62  }

◆ setTranslation()

void ossimAffineTransform::setTranslation ( const ossimDpt translation)
inline

Definition at line 70 of file ossimAffineTransform.h.

71  {
72  theTranslation = translation;
73  computeMatrix();
74  }

Member Data Documentation

◆ theAffineEnabledFlag

bool ossimAffineTransform::theAffineEnabledFlag
protected

Definition at line 101 of file ossimAffineTransform.h.

Referenced by forward(), inverse(), and operator=().

◆ theForwardXform

NEWMAT::Matrix ossimAffineTransform::theForwardXform
protected

Definition at line 103 of file ossimAffineTransform.h.

Referenced by computeMatrix(), forward(), and operator=().

◆ theInverseXform

NEWMAT::Matrix ossimAffineTransform::theInverseXform
protected

Definition at line 104 of file ossimAffineTransform.h.

Referenced by computeMatrix(), inverse(), and operator=().

◆ theRotation

double ossimAffineTransform::theRotation
protected

◆ theScale

ossimDpt ossimAffineTransform::theScale
protected

◆ theTranslation

ossimDpt ossimAffineTransform::theTranslation
protected

The documentation for this class was generated from the following files: