LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::geom::AffineTransform Class Referencefinal

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

Static Public Member Functions

static AffineTransform makeScaling (double s) noexcept
 Construct a new AffineTransform that represents a uniform scaling. More...
 
static AffineTransform makeScaling (double s, double t) noexcept
 Construct a new AffineTransform that represents a non-uniform scaling. More...
 
static AffineTransform makeRotation (Angle t) noexcept
 Construct a new AffineTransform that represents a CCW rotation in radians. More...
 
static AffineTransform makeTranslation (Extent2D translation) noexcept
 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 75 of file AffineTransform.h.

Member Typedef Documentation

◆ Matrix

typedef Eigen::Matrix3d lsst::geom::AffineTransform::Matrix

Definition at line 79 of file AffineTransform.h.

◆ ParameterVector

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

Definition at line 80 of file AffineTransform.h.

◆ TransformDerivativeMatrix

typedef Eigen::Matrix<double, 2, 6> lsst::geom::AffineTransform::TransformDerivativeMatrix

Definition at line 81 of file AffineTransform.h.

Member Enumeration Documentation

◆ Parameters

Constructor & Destructor Documentation

◆ AffineTransform() [1/10]

lsst::geom::AffineTransform::AffineTransform ( )
inlinenoexcept

Construct an empty (identity) AffineTransform.

Definition at line 84 of file AffineTransform.h.

84 : _linear(), _translation() {}

◆ AffineTransform() [2/10]

lsst::geom::AffineTransform::AffineTransform ( Eigen::Matrix3d const &  matrix)
inlineexplicitnoexcept

Construct an AffineTransform from a 3x3 matrix.

Definition at line 87 of file AffineTransform.h.

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

◆ AffineTransform() [3/10]

lsst::geom::AffineTransform::AffineTransform ( Eigen::Matrix2d const &  linear)
inlineexplicitnoexcept

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

Definition at line 91 of file AffineTransform.h.

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

◆ AffineTransform() [4/10]

lsst::geom::AffineTransform::AffineTransform ( Eigen::Vector2d const &  translation)
inlineexplicitnoexcept

Construct a translation-only AffineTransform from a vector.

Definition at line 94 of file AffineTransform.h.

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

◆ AffineTransform() [5/10]

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

Construct an AffineTransform from a 2x2 matrix and vector.

Definition at line 98 of file AffineTransform.h.

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

◆ AffineTransform() [6/10]

lsst::geom::AffineTransform::AffineTransform ( LinearTransform const &  linear)
inlinenoexcept

Construct an AffineTransform from a LinearTransform.

Definition at line 102 of file AffineTransform.h.

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

◆ AffineTransform() [7/10]

lsst::geom::AffineTransform::AffineTransform ( Extent2D const &  translation)
inlineexplicitnoexcept

Construct a translation-only AffineTransform from an Extent2D.

Definition at line 105 of file AffineTransform.h.

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

◆ AffineTransform() [8/10]

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

Construct an AffineTransform from a LinearTransform and Extent2D.

Definition at line 108 of file AffineTransform.h.

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

◆ AffineTransform() [9/10]

lsst::geom::AffineTransform::AffineTransform ( AffineTransform const &  )
defaultnoexcept

◆ AffineTransform() [10/10]

lsst::geom::AffineTransform::AffineTransform ( AffineTransform &&  )
defaultnoexcept

◆ ~AffineTransform()

lsst::geom::AffineTransform::~AffineTransform ( )
defaultnoexcept

Member Function Documentation

◆ dTransform() [1/2]

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

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

Definition at line 58 of file AffineTransform.cc.

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

◆ dTransform() [2/2]

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

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

Definition at line 66 of file AffineTransform.cc.

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

◆ getLinear() [1/2]

LinearTransform const& lsst::geom::AffineTransform::getLinear ( ) const
inlinenoexcept

Definition at line 144 of file AffineTransform.h.

144 { return _linear; }

◆ getLinear() [2/2]

LinearTransform& lsst::geom::AffineTransform::getLinear ( )
inlinenoexcept

Definition at line 145 of file AffineTransform.h.

145 { return _linear; }

◆ getMatrix()

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

Return the transform as a full 3x3 matrix.

Definition at line 47 of file AffineTransform.cc.

◆ getParameterVector()

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

Return the transform matrix elements as a parameter vector.

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

Definition at line 32 of file AffineTransform.cc.

◆ getTranslation() [1/2]

Extent2D const& lsst::geom::AffineTransform::getTranslation ( ) const
inlinenoexcept

Definition at line 141 of file AffineTransform.h.

141 { return _translation; }

◆ getTranslation() [2/2]

Extent2D& lsst::geom::AffineTransform::getTranslation ( )
inlinenoexcept

Definition at line 142 of file AffineTransform.h.

142 { return _translation; }

◆ inverted()

AffineTransform const lsst::geom::AffineTransform::inverted ( ) const

Return the inverse transform.

Exceptions
lsst::geom::SingularTransformExceptionif not invertible

Definition at line 53 of file AffineTransform.cc.

53  {
54  LinearTransform inv(getLinear().inverted());
55  return AffineTransform(inv, -inv(getTranslation()));
56 }
LinearTransform const & getLinear() const noexcept
AffineTransform const inverted() const
Return the inverse transform.
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.
Extent2D const & getTranslation() const noexcept

◆ isIdentity()

bool lsst::geom::AffineTransform::isIdentity ( ) const
inlinenoexcept

Whether the transform is a no-op.

Definition at line 125 of file AffineTransform.h.

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

◆ makeRotation()

static AffineTransform lsst::geom::AffineTransform::makeRotation ( Angle  t)
inlinestaticnoexcept

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 247 of file AffineTransform.h.

247  {
249  }
static LinearTransform makeRotation(Angle t) noexcept
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.

◆ makeScaling() [1/2]

static AffineTransform lsst::geom::AffineTransform::makeScaling ( double  s)
inlinestaticnoexcept

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 215 of file AffineTransform.h.

215  {
217  }
solver_t * s
static LinearTransform makeScaling(double s) noexcept
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.

◆ makeScaling() [2/2]

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

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 232 of file AffineTransform.h.

232  {
234  }
solver_t * s
static LinearTransform makeScaling(double s) noexcept
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.

◆ makeTranslation()

static AffineTransform lsst::geom::AffineTransform::makeTranslation ( Extent2D  translation)
inlinestaticnoexcept

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 263 of file AffineTransform.h.

263  {
264  return AffineTransform(translation);
265  }
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.

◆ operator()() [1/2]

Point2D lsst::geom::AffineTransform::operator() ( Point2D const &  p) const
inlinenoexcept

Transform a Point object.

The result is affected by the translation parameters of the transform

Definition at line 132 of file AffineTransform.h.

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

◆ operator()() [2/2]

Extent2D lsst::geom::AffineTransform::operator() ( Extent2D const &  p) const
inlinenoexcept

Transform an Extent object.

The result is unaffected by the translation parameters of the transform

Definition at line 139 of file AffineTransform.h.

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

◆ operator*()

AffineTransform lsst::geom::AffineTransform::operator* ( AffineTransform const &  other) const
inlinenoexcept

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

Definition at line 171 of file AffineTransform.h.

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

◆ operator+()

AffineTransform lsst::geom::AffineTransform::operator+ ( AffineTransform const &  other)
inlinenoexcept

Definition at line 185 of file AffineTransform.h.

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

◆ operator+=()

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

Definition at line 179 of file AffineTransform.h.

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

◆ operator-()

AffineTransform lsst::geom::AffineTransform::operator- ( AffineTransform const &  other)
inlinenoexcept

Definition at line 197 of file AffineTransform.h.

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

◆ operator-=()

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

Definition at line 191 of file AffineTransform.h.

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

◆ operator=() [1/2]

AffineTransform& lsst::geom::AffineTransform::operator= ( AffineTransform const &  )
defaultnoexcept

◆ operator=() [2/2]

AffineTransform& lsst::geom::AffineTransform::operator= ( AffineTransform &&  )
defaultnoexcept

◆ operator[]() [1/2]

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

Definition at line 165 of file AffineTransform.h.

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

◆ operator[]() [2/2]

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

Definition at line 166 of file AffineTransform.h.

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

◆ setParameterVector()

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

Set the transform matrix elements from a parameter vector.

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

Definition at line 38 of file AffineTransform.cc.

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

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