USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::Affine Class Reference
[Math]

#include <Affine.h>

Collaboration diagram for Isis::Affine:

Collaboration graph
[legend]
List of all members.

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

For internal use only.

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
History:
2007-07-12 Debbie A. Cook, Added methods Coefficients and InverseCoefficients
History:
2008-06-18 Christopher Austin - Added documentation
History:
2008-10-29 Steven Lambright - Corrected usage of std::vector, problem pointed out by "novas0x2a" (Support Forum Member)

Definition at line 73 of file Affine.h.

Public Member Functions

 Affine ()
 Constructs an Affine transform.
 ~Affine ()
 Destroys the Affine object.
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.
void Identity ()
 Set the forward and inverse affine transform to the identity.
void Translate (double tx, double ty)
 Apply a translation to the current affine transform.
void Rotate (double rot)
 Apply a translation to the current affine transform.
void Scale (double scaleFactor)
 Apply a scale to the current affine transform.
void Compute (double x, double y)
 Compute (xp,yp) given (x,y).
double xp () const
 Returns the computed x'.
double yp () const
 Returns the computed y'.
void ComputeInverse (double xp, double yp)
 Compute (x,y) given (xp,yp).
double x () const
 Returns the computed x.
double y () const
 Returns the computed y.
std::vector< double > Coefficients (int var)
 Return the affine coeffients for the entered variable (1 or 2).
std::vector< double > InverseCoefficients (int var)
 Return the inverse affine coeffients for the entered variable (1 or 2).

Private Attributes

TNT::Array2D< double > p_matrix
 Affine forward matrix.
TNT::Array2D< double > p_invmat
 Affine inverse matrix.
double p_x
 x value of the (x,y) coordinate
double p_y
 y value of the (x,y) coordinate
double p_xp
 x' value of the (x',y') coordinate
double p_yp
 y' value of the (x',y') coordinate


Constructor & Destructor Documentation

Isis::Affine::Affine  ) 
 

Constructs an Affine transform.

The default transform is the identity.

Definition at line 41 of file Affine.cpp.

References Identity().

Isis::Affine::~Affine  ) 
 

Destroys the Affine object.

Definition at line 46 of file Affine.cpp.


Member Function Documentation

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:
var The coefficient vector index (1 or 2)

Definition at line 254 of file Affine.cpp.

References p_matrix.

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

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:
x The transformation x factor
y The transformation y factor

Definition at line 227 of file Affine.cpp.

References p_matrix, p_x, p_xp, p_y, and p_yp.

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

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:
xp The inverse transformation xp factor
yp The inverse transformation yp factor

Definition at line 241 of file Affine.cpp.

References p_invmat, p_x, p_xp, p_y, and p_yp.

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

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 52 of file Affine.cpp.

Referenced by Affine(), Isis::Chip::Load(), and Isis::Chip::TackCube().

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:
var The inverse coefficient vector index

Definition at line 269 of file Affine.cpp.

References p_invmat.

void Isis::Affine::Rotate double  angle  ) 
 

Apply a translation to the current affine transform.

Parameters:
angle degrees of counterclockwise rotation

Definition at line 174 of file Affine.cpp.

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

void Isis::Affine::Scale double  scaleFactor  ) 
 

Apply a scale to the current affine transform.

Parameters:
scaleFactor The scale factor

Definition at line 203 of file Affine.cpp.

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

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:
x The transformation x coordinates
y The transformation y coordinates
xp The transformation xp coordinates
yp The transformation yp coordinates
n The number of coordiante pairs
Exceptions:
Isis::iException::Math - Affine transform not invertible

Definition at line 79 of file Affine.cpp.

References Isis::LeastSquares::AddKnown().

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

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

Apply a translation to the current affine transform.

Parameters:
tx translatation to add to x'
ty translation to add to y'

Definition at line 152 of file Affine.cpp.

Referenced by Isis::Chip::Load(), and Isis::Chip::TackCube().

double Isis::Affine::x  )  const [inline]
 

Returns the computed x.

Definition at line 95 of file Affine.h.

References p_x.

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

double Isis::Affine::xp  )  const [inline]
 

Returns the computed x'.

Definition at line 87 of file Affine.h.

References p_xp.

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

double Isis::Affine::y  )  const [inline]
 

Returns the computed y.

Definition at line 98 of file Affine.h.

References p_y.

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

double Isis::Affine::yp  )  const [inline]
 

Returns the computed y'.

Definition at line 90 of file Affine.h.

References p_yp.

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


Member Data Documentation

TNT::Array2D<double> Isis::Affine::p_invmat [private]
 

Affine inverse matrix.

Definition at line 105 of file Affine.h.

Referenced by ComputeInverse(), and InverseCoefficients().

TNT::Array2D<double> Isis::Affine::p_matrix [private]
 

Affine forward matrix.

Definition at line 104 of file Affine.h.

Referenced by Coefficients(), and Compute().

double Isis::Affine::p_x [private]
 

x value of the (x,y) coordinate

Definition at line 107 of file Affine.h.

Referenced by Compute(), ComputeInverse(), and x().

double Isis::Affine::p_xp [private]
 

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

Definition at line 109 of file Affine.h.

Referenced by Compute(), ComputeInverse(), and xp().

double Isis::Affine::p_y [private]
 

y value of the (x,y) coordinate

Definition at line 108 of file Affine.h.

Referenced by Compute(), ComputeInverse(), and y().

double Isis::Affine::p_yp [private]
 

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

Definition at line 110 of file Affine.h.

Referenced by Compute(), ComputeInverse(), and yp().


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