LSSTApplications  12.1-5-gbdcc3ab+2,15.0+13,15.0+26,15.0-1-g19261fa+17,15.0-1-g60afb23+26,15.0-1-g615e0bb+18,15.0-1-g788a293+26,15.0-1-ga91101e+26,15.0-1-gae1598d+12,15.0-1-gd076f1f+24,15.0-1-gdf18595+5,15.0-1-gf4f1c34+12,15.0-11-g7db6e543+4,15.0-12-g3681e7a+4,15.0-15-gc15de322,15.0-16-g83b84f4,15.0-2-g100d730+19,15.0-2-g1f9c9cf+4,15.0-2-g8aea5f4+1,15.0-2-gf38729e+21,15.0-29-ga12a2b06e,15.0-3-g11fe1a0+14,15.0-3-g707930d+3,15.0-3-g9103c06+12,15.0-3-gd3cbb57+3,15.0-4-g2d82b59,15.0-4-g535e784+10,15.0-4-g92ca6c3+4,15.0-4-gf906033+2,15.0-5-g23e394c+14,15.0-5-g4be42a9,15.0-6-g69628aa,15.0-6-g86e3f3d+1,15.0-6-gfa9b38f+4,15.0-7-g949993c+3,15.0-8-g67a62d3+1,15.0-8-gcf05001+1,15.0-9-g1e7c341+1,w.2018.21
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::afw::geom::AffineTransform Class Reference

An affine coordinate transformation consisting of a linear transformation and an offset. More...

#include <AffineTransform.h>

Public Types

enum  Parameters {
  XX = 0, YX = 1, XY = 2, YY = 3,
  X = 4, Y = 5
}
 
typedef Eigen::Matrix3d Matrix
 
typedef Eigen::Matrix< double, 6, 1 > ParameterVector
 
typedef Eigen::Matrix< double, 2, 6 > TransformDerivativeMatrix
 

Public Member Functions

 AffineTransform ()
 Construct an empty (identity) AffineTransform. More...
 
 AffineTransform (Eigen::Matrix3d const &matrix)
 Construct an AffineTransform from a 3x3 matrix. More...
 
 AffineTransform (Eigen::Matrix2d const &linear)
 Construct an AffineTransform with no translation from a 2x2 matrix. More...
 
 AffineTransform (Eigen::Vector2d const &translation)
 Construct a translation-only AffineTransform from a vector. More...
 
 AffineTransform (Eigen::Matrix2d const &linear, Eigen::Vector2d const &translation)
 Construct an AffineTransform from a 2x2 matrix and vector. More...
 
 AffineTransform (LinearTransform const &linear)
 Construct an AffineTransform from a LinearTransform. More...
 
 AffineTransform (Extent2D const &translation)
 Construct a translation-only AffineTransform from an Extent2D. More...
 
 AffineTransform (LinearTransform const &linear, Extent2D const &translation)
 Construct an AffineTransform from a LinearTransform and Extent2D. More...
 
 AffineTransform (AffineTransform const &)=default
 
 AffineTransform (AffineTransform &&)=default
 
 ~AffineTransform ()=default
 
AffineTransform const invert () const
 Return the inverse transform. More...
 
bool isIdentity () const
 Whether the transform is a no-op. More...
 
Point2D operator() (Point2D const &p) const
 Transform a Point object. More...
 
Extent2D operator() (Extent2D const &p) const
 Transform an Extent object. More...
 
Extent2D const & getTranslation () const
 
Extent2DgetTranslation ()
 
LinearTransform const & getLinear () const
 
LinearTransformgetLinear ()
 
Matrix const getMatrix () const
 Return the transform as a full 3x3 matrix. More...
 
ParameterVector const getParameterVector () const
 Return the transform matrix elements as a parameter vector. More...
 
void setParameterVector (ParameterVector const &vector)
 Set the transform matrix elements from a parameter vector. More...
 
double & operator[] (int i)
 
double operator[] (int i) const
 
AffineTransform operator* (AffineTransform const &other) const
 Construct a new AffineTransform from two others: (B * A)(p) = B(A(p)) More...
 
AffineTransformoperator= (AffineTransform const &)=default
 
AffineTransformoperator= (AffineTransform &&)=default
 
AffineTransformoperator+= (AffineTransform const &other)
 
AffineTransform operator+ (AffineTransform const &other)
 
AffineTransformoperator-= (AffineTransform const &other)
 
AffineTransform operator- (AffineTransform const &other)
 
TransformDerivativeMatrix dTransform (Point2D const &input) const
 Take the derivative of (*this)(input) w.r.t the transform elements. More...
 
TransformDerivativeMatrix dTransform (Extent2D const &input) const
 Take the derivative of (*this)(input) w.r.t the transform elements. More...
 

Static Public Member Functions

static AffineTransform makeScaling (double s)
 Construct a new AffineTransform that represents a uniform scaling. More...
 
static AffineTransform makeScaling (double s, double t)
 Construct a new AffineTransform that represents a non-uniform scaling. More...
 
static AffineTransform makeRotation (Angle t)
 Construct a new AffineTransform that represents a CCW rotation in radians. More...
 
static AffineTransform makeTranslation (Extent2D translation)
 Construct a new AffineTransform that represents a pure translation. More...
 

Detailed Description

An affine coordinate transformation consisting of a linear transformation and an offset.

The transform is represented by a matrix \( \mathbf{M} \) such that

\[ \left[\begin{array}{ c } x_f \\ y_f \\ 1 \end{array}\right] = \mathbf{M} \left[\begin{array}{ c } x_i \\ y_i \\ 1 \end{array}\right] \]

where \((x_i,y_i)\) are the input coordinates and \((x_f,y_f)\) are the output coordinates.

If \( x_f(x_i,y_i) \) and \( y_f(x_i,y_i) \) are continuous differentiable functions, then

\[ \mathbf{M} = \left[\begin{array}{ c c c } \displaystyle\frac{\partial x_f}{\partial x_i} & \displaystyle\frac{\partial x_f}{\partial y_i} & x_f \\ \displaystyle\frac{\partial y_f}{\partial x_i} & \displaystyle\frac{\partial y_f}{\partial y_i} & y_f \\ \displaystyle 0 & \displaystyle 0 & \displaystyle 1 \end{array}\right] \]

evaluated at \((x_i,y_i)\).

The 2x2 upper left corner of \( \mathbf{M} \) is the linear part of the transform is simply the Jacobian of the mapping between \((x_i,y_i)\) and \((x_f,y_f)\).

Definition at line 77 of file AffineTransform.h.

Member Typedef Documentation

◆ Matrix

Definition at line 81 of file AffineTransform.h.

◆ ParameterVector

typedef Eigen::Matrix<double, 6, 1> lsst::afw::geom::AffineTransform::ParameterVector

Definition at line 82 of file AffineTransform.h.

◆ TransformDerivativeMatrix

Definition at line 83 of file AffineTransform.h.

Member Enumeration Documentation

◆ Parameters

Constructor & Destructor Documentation

◆ AffineTransform() [1/10]

lsst::afw::geom::AffineTransform::AffineTransform ( )
inline

Construct an empty (identity) AffineTransform.

Definition at line 86 of file AffineTransform.h.

86 : _linear(), _translation() {}

◆ AffineTransform() [2/10]

lsst::afw::geom::AffineTransform::AffineTransform ( Eigen::Matrix3d const &  matrix)
inlineexplicit

Construct an AffineTransform from a 3x3 matrix.

Definition at line 89 of file AffineTransform.h.

90  : _linear(matrix.block<2, 2>(0, 0)), _translation(matrix.block<2, 1>(0, 2)) {}

◆ AffineTransform() [3/10]

lsst::afw::geom::AffineTransform::AffineTransform ( Eigen::Matrix2d const &  linear)
inlineexplicit

Construct an AffineTransform with no translation from a 2x2 matrix.

Definition at line 93 of file AffineTransform.h.

93 : _linear(linear), _translation() {}

◆ AffineTransform() [4/10]

lsst::afw::geom::AffineTransform::AffineTransform ( Eigen::Vector2d const &  translation)
inlineexplicit

Construct a translation-only AffineTransform from a vector.

Definition at line 96 of file AffineTransform.h.

96 : _linear(), _translation(translation) {}

◆ AffineTransform() [5/10]

lsst::afw::geom::AffineTransform::AffineTransform ( Eigen::Matrix2d const &  linear,
Eigen::Vector2d const &  translation 
)
inlineexplicit

Construct an AffineTransform from a 2x2 matrix and vector.

Definition at line 99 of file AffineTransform.h.

100  : _linear(linear), _translation(translation) {}

◆ AffineTransform() [6/10]

lsst::afw::geom::AffineTransform::AffineTransform ( LinearTransform const &  linear)
inline

Construct an AffineTransform from a LinearTransform.

Definition at line 103 of file AffineTransform.h.

103 : _linear(linear), _translation() {}

◆ AffineTransform() [7/10]

lsst::afw::geom::AffineTransform::AffineTransform ( Extent2D const &  translation)
inlineexplicit

Construct a translation-only AffineTransform from an Extent2D.

Definition at line 106 of file AffineTransform.h.

106 : _linear(), _translation(translation) {}

◆ AffineTransform() [8/10]

lsst::afw::geom::AffineTransform::AffineTransform ( LinearTransform const &  linear,
Extent2D const &  translation 
)
inlineexplicit

Construct an AffineTransform from a LinearTransform and Extent2D.

Definition at line 109 of file AffineTransform.h.

110  : _linear(linear), _translation(translation) {}

◆ AffineTransform() [9/10]

lsst::afw::geom::AffineTransform::AffineTransform ( AffineTransform const &  )
default

◆ AffineTransform() [10/10]

lsst::afw::geom::AffineTransform::AffineTransform ( AffineTransform &&  )
default

◆ ~AffineTransform()

lsst::afw::geom::AffineTransform::~AffineTransform ( )
default

Member Function Documentation

◆ dTransform() [1/2]

AffineTransform::TransformDerivativeMatrix lsst::afw::geom::AffineTransform::dTransform ( Point2D const &  input) const

Take the derivative of (*this)(input) w.r.t the transform elements.

Definition at line 60 of file AffineTransform.cc.

60  {
61  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
62  r.block<2, 4>(0, 0) = getLinear().dTransform(input);
63  r(0, X) = 1.0;
64  r(1, Y) = 1.0;
65  return r;
66 }
Eigen::Matrix< double, 2, 6 > TransformDerivativeMatrix
LinearTransform const & getLinear() const
TransformDerivativeMatrix dTransform(Point2D const &input) const
Derivative of (*this)(input) with respect to the transform elements (for Point).

◆ dTransform() [2/2]

AffineTransform::TransformDerivativeMatrix lsst::afw::geom::AffineTransform::dTransform ( Extent2D const &  input) const

Take the derivative of (*this)(input) w.r.t the transform elements.

Definition at line 68 of file AffineTransform.cc.

68  {
69  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
70  r.block<2, 4>(0, 0) = getLinear().dTransform(input);
71  return r;
72 }
Eigen::Matrix< double, 2, 6 > TransformDerivativeMatrix
LinearTransform const & getLinear() const
TransformDerivativeMatrix dTransform(Point2D const &input) const
Derivative of (*this)(input) with respect to the transform elements (for Point).

◆ getLinear() [1/2]

LinearTransform const& lsst::afw::geom::AffineTransform::getLinear ( ) const
inline

Definition at line 143 of file AffineTransform.h.

143 { return _linear; }

◆ getLinear() [2/2]

LinearTransform& lsst::afw::geom::AffineTransform::getLinear ( )
inline

Definition at line 144 of file AffineTransform.h.

144 { return _linear; }

◆ getMatrix()

AffineTransform::Matrix const lsst::afw::geom::AffineTransform::getMatrix ( ) const

Return the transform as a full 3x3 matrix.

Definition at line 49 of file AffineTransform.cc.

◆ getParameterVector()

AffineTransform::ParameterVector const lsst::afw::geom::AffineTransform::getParameterVector ( ) const

Return the transform matrix elements as a parameter vector.

The elements will be ordered XX, YX, XY, YY, X, Y

Definition at line 34 of file AffineTransform.cc.

◆ getTranslation() [1/2]

Extent2D const& lsst::afw::geom::AffineTransform::getTranslation ( ) const
inline

Definition at line 140 of file AffineTransform.h.

140 { return _translation; }

◆ getTranslation() [2/2]

Extent2D& lsst::afw::geom::AffineTransform::getTranslation ( )
inline

Definition at line 141 of file AffineTransform.h.

141 { return _translation; }

◆ invert()

AffineTransform const lsst::afw::geom::AffineTransform::invert ( ) const

Return the inverse transform.

Exceptions
lsst::afw::geom::SingularTransformExceptionis not invertible

Definition at line 55 of file AffineTransform.cc.

55  {
56  LinearTransform inv(getLinear().invert());
57  return AffineTransform(inv, -inv(getTranslation()));
58 }
LinearTransform const & getLinear() const
AffineTransform()
Construct an empty (identity) AffineTransform.
AffineTransform const invert() const
Return the inverse transform.
Extent2D const & getTranslation() const

◆ isIdentity()

bool lsst::afw::geom::AffineTransform::isIdentity ( ) const
inline

Whether the transform is a no-op.

Definition at line 124 of file AffineTransform.h.

124 { return getMatrix().isIdentity(); }
Matrix const getMatrix() const
Return the transform as a full 3x3 matrix.

◆ makeRotation()

static AffineTransform lsst::afw::geom::AffineTransform::makeRotation ( Angle  t)
inlinestatic

Construct a new AffineTransform that represents a CCW rotation in radians.

Returns
An AffineTransform with matrix \( \left[\begin{array}{ c c c } \cos t & -\sin t & 0 \\ \sin t & \cos t & 0 \\ 0 & 0 & 1 \\ \end{array}\right] \)

Definition at line 244 of file AffineTransform.h.

static LinearTransform makeRotation(Angle t)
AffineTransform()
Construct an empty (identity) AffineTransform.

◆ makeScaling() [1/2]

static AffineTransform lsst::afw::geom::AffineTransform::makeScaling ( double  s)
inlinestatic

Construct a new AffineTransform that represents a uniform scaling.

Returns
An AffineTransform with matrix \( \left[\begin{array}{ c c c } s & 0 & 0 \\ 0 & s & 0 \\ 0 & 0 & 1 \\ \end{array}\right] \)

Definition at line 214 of file AffineTransform.h.

static LinearTransform makeScaling(double s)
solver_t * s
AffineTransform()
Construct an empty (identity) AffineTransform.

◆ makeScaling() [2/2]

static AffineTransform lsst::afw::geom::AffineTransform::makeScaling ( double  s,
double  t 
)
inlinestatic

Construct a new AffineTransform that represents a non-uniform scaling.

Returns
An AffineTransform with matrix \( \left[\begin{array}{ c c c } s & 0 & 0 \\ 0 & t & 0 \\ 0 & 0 & 1 \\ \end{array}\right] \)

Definition at line 229 of file AffineTransform.h.

229  {
231  }
static LinearTransform makeScaling(double s)
solver_t * s
AffineTransform()
Construct an empty (identity) AffineTransform.

◆ makeTranslation()

static AffineTransform lsst::afw::geom::AffineTransform::makeTranslation ( Extent2D  translation)
inlinestatic

Construct a new AffineTransform that represents a pure translation.

Returns
An AffineTransform with matrix \( \left[\begin{array}{ c c c } 0 & 0 & translation.getX() \\ 0 & 0 & translation.getY() \\ 0 & 0 & 1 \\ \end{array}\right] \)

Definition at line 258 of file AffineTransform.h.

258 { return AffineTransform(translation); }
AffineTransform()
Construct an empty (identity) AffineTransform.

◆ operator()() [1/2]

Point2D lsst::afw::geom::AffineTransform::operator() ( Point2D const &  p) const
inline

Transform a Point object.

The result is affected by the translation parameters of the transform

Definition at line 131 of file AffineTransform.h.

131 { return Point2D(_linear(p) + _translation); }
Point< double, 2 > Point2D
Definition: Point.h:304

◆ operator()() [2/2]

Extent2D lsst::afw::geom::AffineTransform::operator() ( Extent2D const &  p) const
inline

Transform an Extent object.

The result is unaffected by the translation parameters of the transform

Definition at line 138 of file AffineTransform.h.

138 { return Extent2D(_linear(p)); }
Extent< double, 2 > Extent2D
Definition: Extent.h:383

◆ operator*()

AffineTransform lsst::afw::geom::AffineTransform::operator* ( AffineTransform const &  other) const
inline

Construct a new AffineTransform from two others: (B * A)(p) = B(A(p))

Definition at line 170 of file AffineTransform.h.

170  {
171  return AffineTransform(getLinear() * other.getLinear(),
172  getLinear()(other.getTranslation()) + getTranslation());
173  }
LinearTransform const & getLinear() const
AffineTransform()
Construct an empty (identity) AffineTransform.
ItemVariant const * other
Definition: Schema.cc:55
Extent2D const & getTranslation() const

◆ operator+()

AffineTransform lsst::afw::geom::AffineTransform::operator+ ( AffineTransform const &  other)
inline

Definition at line 184 of file AffineTransform.h.

184  {
185  AffineTransform tmp(*this);
186  tmp += other;
187  return tmp;
188  }
AffineTransform()
Construct an empty (identity) AffineTransform.
ItemVariant const * other
Definition: Schema.cc:55

◆ operator+=()

AffineTransform& lsst::afw::geom::AffineTransform::operator+= ( AffineTransform const &  other)
inline

Definition at line 178 of file AffineTransform.h.

178  {
179  _linear += other._linear;
180  _translation += other._translation;
181  return *this;
182  }
ItemVariant const * other
Definition: Schema.cc:55

◆ operator-()

AffineTransform lsst::afw::geom::AffineTransform::operator- ( AffineTransform const &  other)
inline

Definition at line 196 of file AffineTransform.h.

196  {
197  AffineTransform tmp(*this);
198  tmp -= other;
199  return tmp;
200  }
AffineTransform()
Construct an empty (identity) AffineTransform.
ItemVariant const * other
Definition: Schema.cc:55

◆ operator-=()

AffineTransform& lsst::afw::geom::AffineTransform::operator-= ( AffineTransform const &  other)
inline

Definition at line 190 of file AffineTransform.h.

190  {
191  _linear -= other._linear;
192  _translation -= other._translation;
193  return *this;
194  }
ItemVariant const * other
Definition: Schema.cc:55

◆ operator=() [1/2]

AffineTransform& lsst::afw::geom::AffineTransform::operator= ( AffineTransform const &  )
default

◆ operator=() [2/2]

AffineTransform& lsst::afw::geom::AffineTransform::operator= ( AffineTransform &&  )
default

◆ operator[]() [1/2]

double& lsst::afw::geom::AffineTransform::operator[] ( int  i)
inline

Definition at line 164 of file AffineTransform.h.

164 { return (i < 4) ? _linear[i] : _translation[i - 4]; }

◆ operator[]() [2/2]

double lsst::afw::geom::AffineTransform::operator[] ( int  i) const
inline

Definition at line 165 of file AffineTransform.h.

165 { return (i < 4) ? _linear[i] : _translation[i - 4]; }

◆ setParameterVector()

void lsst::afw::geom::AffineTransform::setParameterVector ( AffineTransform::ParameterVector const &  vector)

Set the transform matrix elements from a parameter vector.

The parameter vector is ordered XX, YX, XY, YY, X, Y

Definition at line 40 of file AffineTransform.cc.

40  {
41  (*this)[XX] = vector[XX];
42  (*this)[XY] = vector[XY];
43  (*this)[X] = vector[X];
44  (*this)[YX] = vector[YX];
45  (*this)[YY] = vector[YY];
46  (*this)[Y] = vector[Y];
47 }

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