LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+bd2ed33bd6,g1470d8bcf6+c6d6eb38e2,g14a832a312+9d12ad093c,g2079a07aa2+86d27d4dc4,g2305ad1205+91a32aca49,g295015adf3+88246b6574,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+c34e8be1fa,g487adcacf7+85dcfbcc36,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ea1711114f,g5a732f18d5+53520f316c,g64a986408d+bd2ed33bd6,g858d7b2824+bd2ed33bd6,g8a8a8dda67+585e252eca,g99cad8db69+016a06b37a,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+b6d7b42999,gc120e1dc64+f745648b3a,gc28159a63d+0e5473021a,gcf0d15dbbd+c34e8be1fa,gdaeeff99f8+f9a426f77a,ge6526c86ff+508d0e0a30,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+8d59551888,gf1cff7945b+bd2ed33bd6,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
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.
 
 AffineTransform (Eigen::Matrix3d const &matrix) noexcept
 Construct an AffineTransform from a 3x3 matrix.
 
 AffineTransform (Eigen::Matrix2d const &linear) noexcept
 Construct an AffineTransform with no translation from a 2x2 matrix.
 
 AffineTransform (Eigen::Vector2d const &translation) noexcept
 Construct a translation-only AffineTransform from a vector.
 
 AffineTransform (Eigen::Matrix2d const &linear, Eigen::Vector2d const &translation) noexcept
 Construct an AffineTransform from a 2x2 matrix and vector.
 
 AffineTransform (LinearTransform const &linear) noexcept
 Construct an AffineTransform from a LinearTransform.
 
 AffineTransform (Extent2D const &translation) noexcept
 Construct a translation-only AffineTransform from an Extent2D.
 
 AffineTransform (LinearTransform const &linear, Extent2D const &translation) noexcept
 Construct an AffineTransform from a LinearTransform and Extent2D.
 
 AffineTransform (AffineTransform const &) noexcept=default
 
 AffineTransform (AffineTransform &&) noexcept=default
 
 ~AffineTransform () noexcept=default
 
AffineTransform const inverted () const
 Return the inverse transform.
 
bool isIdentity () const noexcept
 Whether the transform is a no-op.
 
Point2D operator() (Point2D const &p) const noexcept
 Transform a Point object.
 
Extent2D operator() (Extent2D const &p) const noexcept
 Transform an Extent object.
 
double applyX (double x, double y) const noexcept
 Transform a point given and returned as separate double values.
 
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.
 
ParameterVector const getParameterVector () const noexcept
 Return the transform matrix elements as a parameter vector.
 
void setParameterVector (ParameterVector const &vector) noexcept
 Set the transform matrix elements from a parameter vector.
 
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))
 
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.
 
TransformDerivativeMatrix dTransform (Extent2D const &input) const noexcept
 Take the derivative of (*this)(input) w.r.t the transform elements.
 

Static Public Member Functions

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

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(); }
int y
Definition SpanSet.cc:48
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.
Extent2D const & getTranslation() const noexcept
AffineTransform() noexcept
Construct an empty (identity) AffineTransform.

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

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