LSST Applications  21.0.0+3c14b91618,21.0.0+9f51b1e3f7,21.0.0-1-ga51b5d4+6691386486,21.0.0-10-g2408eff+093cbc5a4d,21.0.0-10-g560fb7b+b5197f4bfa,21.0.0-10-gcf60f90+88fef039d6,21.0.0-15-g490e301a+1aca7ce27a,21.0.0-2-g103fe59+a65a629d54,21.0.0-2-g1367e85+7f080822af,21.0.0-2-g45278ab+9f51b1e3f7,21.0.0-2-g5242d73+7f080822af,21.0.0-2-g7f82c8f+20b0e168c7,21.0.0-2-g8f08a60+e6fd6d9ff9,21.0.0-2-ga326454+20b0e168c7,21.0.0-2-gde069b7+66c51b65da,21.0.0-2-gecfae73+1385e31ff3,21.0.0-2-gfc62afb+7f080822af,21.0.0-20-g09baf175d+b753e4a737,21.0.0-3-g357aad2+34cf5c551a,21.0.0-3-g4be5c26+7f080822af,21.0.0-3-g65f322c+013fced60c,21.0.0-3-g7d9da8d+3c14b91618,21.0.0-3-gaa929c8+b5197f4bfa,21.0.0-3-ge02ed75+1caa01c806,21.0.0-4-g3af6bfd+3791265f16,21.0.0-4-g591bb35+1caa01c806,21.0.0-4-g88306b8+fb98652b4f,21.0.0-4-gccdca77+86bf7a300d,21.0.0-4-ge8a399c+b26ce82291,21.0.0-43-g9a3faf29+c9d24e8573,21.0.0-5-g073e055+09d740ccc5,21.0.0-6-g2d4f3f3+9f51b1e3f7,21.0.0-6-g4e60332+1caa01c806,21.0.0-6-g8356267+caf0b8986d,21.0.0-7-g6531d7b+5c053f0a73,21.0.0-7-g98eecf7+3609eddee2,21.0.0-8-ga5967ee+609c2f0a1c,master-gac4afde19b+1caa01c806,w.2021.09
LSST Data Management Base Package
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
 
AffineTransform const inverted () const
 Return the inverse transform. More...
 
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...
 
double applyX (double x, double y) const noexcept
 Transform a point given and returned as separate double values. More...
 
double applyY (double x, double y) const noexcept
 
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...
 

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

◆ applyX()

double lsst::geom::AffineTransform::applyX ( double  x,
double  y 
) const
inlinenoexcept

Transform a point given and returned as separate double values.

This interface is intended primarily for use in Python (where it is vectorized to support NumPy array arguments).

Definition at line 148 of file AffineTransform.h.

148 { return _linear.applyX(x, y) + _translation.getX(); }
double x
int y
Definition: SpanSet.cc:49
double applyX(double x, double y) const noexcept
Transform a point given and returned as separate double values.

◆ applyY()

double lsst::geom::AffineTransform::applyY ( double  x,
double  y 
) const
inlinenoexcept

Definition at line 149 of file AffineTransform.h.

149 { return _linear.applyY(x, y) + _translation.getY(); }
double applyY(double x, double y) const noexcept

◆ dTransform() [1/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 }
Eigen::Matrix< double, 2, 6 > TransformDerivativeMatrix
LinearTransform const & getLinear() const noexcept
TransformDerivativeMatrix dTransform(Point2D const &input) const noexcept
Derivative of (*this)(input) with respect to the transform elements (for Point).

◆ dTransform() [2/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 }

◆ getLinear() [1/2]

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

Definition at line 155 of file AffineTransform.h.

155 { return _linear; }

◆ getLinear() [2/2]

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

Definition at line 156 of file AffineTransform.h.

156 { 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.

47  {
48  Matrix r;
49  r << (*this)[XX], (*this)[XY], (*this)[X], (*this)[YX], (*this)[YY], (*this)[Y], 0.0, 0.0, 1.0;
50  return r;
51 }

◆ 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.

32  {
34  r << (*this)[XX], (*this)[YX], (*this)[XY], (*this)[YY], (*this)[X], (*this)[Y];
35  return r;
36 }
Eigen::Matrix< double, 6, 1 > ParameterVector

◆ getTranslation() [1/2]

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

Definition at line 152 of file AffineTransform.h.

152 { return _translation; }

◆ getTranslation() [2/2]

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

Definition at line 153 of file AffineTransform.h.

153 { 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 }
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 258 of file AffineTransform.h.

258  {
260  }
static LinearTransform makeRotation(Angle t) noexcept

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

226  {
228  }
static LinearTransform makeScaling(double s) noexcept

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

243  {
245  }

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

274  {
275  return AffineTransform(translation);
276  }

◆ operator()() [1/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()() [2/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*()

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

182  {
183  return AffineTransform(getLinear() * other.getLinear(),
184  getLinear()(other.getTranslation()) + getTranslation());
185  }
ItemVariant const * other
Definition: Schema.cc:56

◆ operator+()

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

Definition at line 196 of file AffineTransform.h.

196  {
197  AffineTransform tmp(*this);
198  tmp += other;
199  return tmp;
200  }

◆ operator+=()

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

Definition at line 190 of file AffineTransform.h.

190  {
191  _linear += other._linear;
192  _translation += other._translation;
193  return *this;
194  }

◆ operator-()

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

Definition at line 208 of file AffineTransform.h.

208  {
209  AffineTransform tmp(*this);
210  tmp -= other;
211  return tmp;
212  }

◆ operator-=()

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

Definition at line 202 of file AffineTransform.h.

202  {
203  _linear -= other._linear;
204  _translation -= other._translation;
205  return *this;
206  }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

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

Definition at line 176 of file AffineTransform.h.

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

◆ operator[]() [2/2]

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

Definition at line 177 of file AffineTransform.h.

177 { 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: