Isis 3 Programmer Reference
Isis::Affine Class Reference

Affine basis function. More...

#include <Affine.h>

Collaboration diagram for Isis::Affine:
Collaboration graph

Public Types

typedef TNT::Array2D< double > AMatrix
 Affine Matrix. More...
 

Public Member Functions

 Affine ()
 Constructs an Affine transform. More...
 
 Affine (const AMatrix &a)
 Create Affine transform from matrix. More...
 
 ~Affine ()
 Destroys the Affine object. More...
 
void Solve (const double x[], const double y[], const double xp[], const double yp[], int n)
 Given a set of coordinate pairs (n >= 3), compute the affine transform that best fits the points. More...
 
void Identity ()
 Set the forward and inverse affine transform to the identity. More...
 
void Translate (double tx, double ty)
 Apply a translation to the current affine transform. More...
 
void Rotate (double rot)
 Apply a translation to the current affine transform. More...
 
void Scale (double scaleFactor)
 Apply a scale to the current affine transform. More...
 
void Compute (double x, double y)
 Compute (xp,yp) given (x,y). More...
 
double xp () const
 Returns the computed x'. More...
 
double yp () const
 Returns the computed y'. More...
 
void ComputeInverse (double xp, double yp)
 Compute (x,y) given (xp,yp). More...
 
double x () const
 Returns the computed x. More...
 
double y () const
 Returns the computed y. More...
 
std::vector< double > Coefficients (int var)
 Return the affine coeffients for the entered variable (1 or 2). More...
 
std::vector< double > InverseCoefficients (int var)
 Return the inverse affine coeffients for the entered variable (1 or 2). More...
 
AMatrix Forward () const
 Returns the forward Affine matrix. More...
 
AMatrix Inverse () const
 Returns the inverse Affine matrix. More...
 

Static Public Member Functions

static AMatrix getIdentity ()
 Return an Affine identity matrix. More...
 

Private Member Functions

void checkDims (const AMatrix &am) const
 Checks affine matrix to ensure it is a 3x3 standard form transform. More...
 
AMatrix invert (const AMatrix &a) const
 Compute the inverse of a matrix. More...
 

Private Attributes

AMatrix p_matrix
 Affine forward matrix. More...
 
AMatrix p_invmat
 Affine inverse matrix. More...
 
double p_x
 x value of the (x,y) coordinate More...
 
double p_y
 y value of the (x,y) coordinate More...
 
double p_xp
 x' value of the (x',y') coordinate More...
 
double p_yp
 y' value of the (x',y') coordinate More...
 

Detailed Description

Affine basis function.

An affine transform in two-dimensional space is defined as

x' = Ax + By + C
y' = Dx + Ey + F

This routine allows the programmer to define three or more mappings from (x,y) to (x',y') and will solve for A,B,C,D,E,F.

If the above coefficients can be computed then the inverse of the affine transform exists and will be computed such that

x = A'x' + B'y' + C'
y = D'x' + E'y' + F'

Alternatively (or in combination), translations and rotations can be applied to create a transform.

See also
http://www.gnome.org/~mathieu/libart/libart-affine-transformation-matrices.html
Author
2005-03-24 Jeff Anderson
Todo:

Allow the programmer to apply scale and shear.

Write multiplaction method (operator*) for Affine * Affine.

History:

2006-08-03 Tracie Sucharski, Added Scale method

2007-07-12 Debbie A. Cook, Added methods Coefficients and InverseCoefficients

2008-06-18 Christopher Austin - Added documentation

2008-10-29 Steven Lambright - Corrected usage of std::vector, problem pointed out by "novas0x2a" (Support Forum Member)

2009-07-24 Kris Becker Introduced the AMatrix typedef; added new constructor that accepts an AMatrix; added static method to return an Affine identity matrix; added methods to retrieve forward and inverse AMatrixs; added new method that inverts the matrix.

2010-11-18 Kris Becker Fixed bug in inverse representation when scaling is applied to the current transform.

2017-06-28 Makayla Shepherd - Updated documentation. References #4807.

Definition at line 80 of file Affine.h.

Member Typedef Documentation

◆ AMatrix

typedef TNT::Array2D<double> Isis::Affine::AMatrix

Affine Matrix.

Definition at line 82 of file Affine.h.

Constructor & Destructor Documentation

◆ Affine() [1/2]

Isis::Affine::Affine ( )

Constructs an Affine transform.

The default transform is the identity.

Definition at line 44 of file Affine.cpp.

◆ Affine() [2/2]

Isis::Affine::Affine ( const AMatrix a)

Create Affine transform from matrix.

This constructor creates the affine transform from a forward matrix. The input matrix is checked for the proper dimensions (3x3) and is then inverted to complete the inverse functionality.

The input matrix must be invertable or an exception will be thrown!

Parameters
aForward affine matrix

Definition at line 60 of file Affine.cpp.

◆ ~Affine()

Isis::Affine::~Affine ( )

Destroys the Affine object.

Definition at line 68 of file Affine.cpp.

Member Function Documentation

◆ checkDims()

void Isis::Affine::checkDims ( const AMatrix am) const
private

Checks affine matrix to ensure it is a 3x3 standard form transform.

Parameters
amAffine matrix to validate

Definition at line 265 of file Affine.cpp.

References _FILEINFO_.

◆ Coefficients()

vector< double > Isis::Affine::Coefficients ( int  var)

Return the affine coeffients for the entered variable (1 or 2).

The coefficients are returned in a 3-dimensional vector

Parameters
varThe coefficient vector index (1 or 2)
Returns
vector<double> Vector of coefficients

Definition at line 234 of file Affine.cpp.

Referenced by Isis::CameraFocalPlaneMap::CameraFocalPlaneMap(), and Isis::LoCameraFiducialMap::CreateTrans().

◆ Compute()

void Isis::Affine::Compute ( double  x,
double  y 
)

Compute (xp,yp) given (x,y).

Use the methods xp() and yp() to obtain the results.

Parameters
xThe transformation x factor
yThe transformation y factor

Definition at line 205 of file Affine.cpp.

Referenced by Isis::Chip::Extract().

◆ ComputeInverse()

void Isis::Affine::ComputeInverse ( double  xp,
double  yp 
)

Compute (x,y) given (xp,yp).

Use the methods x() and y() to obtain the results.

Parameters
xpThe inverse transformation xp factor
ypThe inverse transformation yp factor

Definition at line 219 of file Affine.cpp.

◆ Forward()

AMatrix Isis::Affine::Forward ( ) const
inline

Returns the forward Affine matrix.

Returns
AMatrix Forward Affine matrix

Definition at line 142 of file Affine.h.

References p_matrix.

Referenced by Isis::Chip::Extract().

◆ getIdentity()

Affine::AMatrix Isis::Affine::getIdentity ( )
static

Return an Affine identity matrix.

Returns
Affine::AMatrix The identity matrix

Definition at line 75 of file Affine.cpp.

Referenced by Isis::AffineRadio::clone(), Isis::Threshold::hasConverged(), Isis::AffineRadio::operator+=(), and Isis::AffineRadio::Translate().

◆ Identity()

void Isis::Affine::Identity ( )

Set the forward and inverse affine transform to the identity.

That is, xp = x and yp = y for all (x,y).

Definition at line 87 of file Affine.cpp.

◆ Inverse()

AMatrix Isis::Affine::Inverse ( ) const
inline

Returns the inverse Affine matrix.

Returns
AMatrix Inverse Affine matrix

Definition at line 151 of file Affine.h.

References p_invmat.

◆ InverseCoefficients()

vector< double > Isis::Affine::InverseCoefficients ( int  var)

Return the inverse affine coeffients for the entered variable (1 or 2).

The coefficients are returned in a 3-dimensional vector

Parameters
varThe inverse coefficient vector index
Returns
vector<double> Vector of inverse coefficients

Definition at line 251 of file Affine.cpp.

Referenced by Isis::CameraFocalPlaneMap::CameraFocalPlaneMap(), and Isis::LoCameraFiducialMap::CreateTrans().

◆ invert()

Affine::AMatrix Isis::Affine::invert ( const AMatrix a) const
private

Compute the inverse of a matrix.

This method will compute the inverse of an affine matrix for purposes of forward and inverse Affine computations.

Parameters
aMatrix to invert
Returns
Affine::AMatrix The inverted matrix

Definition at line 285 of file Affine.cpp.

References _FILEINFO_.

◆ Rotate()

void Isis::Affine::Rotate ( double  angle)

Apply a translation to the current affine transform.

Parameters
angledegrees of counterclockwise rotation

Definition at line 165 of file Affine.cpp.

References Isis::PI.

◆ Scale()

void Isis::Affine::Scale ( double  scaleFactor)

Apply a scale to the current affine transform.

Parameters
scaleFactorThe scale factor

Definition at line 188 of file Affine.cpp.

◆ Solve()

void Isis::Affine::Solve ( const double  x[],
const double  y[],
const double  xp[],
const double  yp[],
int  n 
)

Given a set of coordinate pairs (n >= 3), compute the affine transform that best fits the points.

If given exactly three coordinates that are not colinear, the fit will be guarenteed to be exact through the points.

Parameters
xThe transformation x coordinates
yThe transformation y coordinates
xpThe transformation xp coordinates
ypThe transformation yp coordinates
nThe number of coordiante pairs
Exceptions
Isis::iException::Math- Affine transform not invertible

Definition at line 106 of file Affine.cpp.

References Isis::LeastSquares::AddKnown(), Isis::BasisFunction::Coefficient(), and Isis::LeastSquares::Solve().

Referenced by Isis::LoCameraFiducialMap::CreateTrans().

◆ Translate()

void Isis::Affine::Translate ( double  tx,
double  ty 
)

Apply a translation to the current affine transform.

Parameters
txtranslatation to add to x'
tytranslation to add to y'

Definition at line 148 of file Affine.cpp.

◆ x()

double Isis::Affine::x ( ) const
inline

Returns the computed x.

Returns
double Computed x

Definition at line 121 of file Affine.h.

References p_x.

◆ xp()

double Isis::Affine::xp ( ) const
inline

Returns the computed x'.

Returns
double Computed x'

Definition at line 101 of file Affine.h.

References p_xp.

Referenced by Isis::Chip::Extract().

◆ y()

double Isis::Affine::y ( ) const
inline

Returns the computed y.

Returns
double Computed y

Definition at line 130 of file Affine.h.

References p_y.

◆ yp()

double Isis::Affine::yp ( ) const
inline

Returns the computed y'.

Returns
double Computed y'

Definition at line 110 of file Affine.h.

References p_yp.

Referenced by Isis::Chip::Extract().

Member Data Documentation

◆ p_invmat

AMatrix Isis::Affine::p_invmat
private

Affine inverse matrix.

Definition at line 157 of file Affine.h.

Referenced by Inverse().

◆ p_matrix

AMatrix Isis::Affine::p_matrix
private

Affine forward matrix.

Definition at line 156 of file Affine.h.

Referenced by Forward().

◆ p_x

double Isis::Affine::p_x
private

x value of the (x,y) coordinate

Definition at line 159 of file Affine.h.

Referenced by x().

◆ p_xp

double Isis::Affine::p_xp
private

x' value of the (x',y') coordinate

Definition at line 161 of file Affine.h.

Referenced by xp().

◆ p_y

double Isis::Affine::p_y
private

y value of the (x,y) coordinate

Definition at line 160 of file Affine.h.

Referenced by y().

◆ p_yp

double Isis::Affine::p_yp
private

y' value of the (x',y') coordinate

Definition at line 162 of file Affine.h.

Referenced by yp().


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