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::LinearTransform Class Reference

A 2D linear coordinate transformation. More...

#include <LinearTransform.h>

Public Types

enum  Parameters { XX = 0, YX = 1, XY = 2, YY = 3 }
 
typedef Eigen::Matrix< double, 4, 1 > ParameterVector
 
typedef Eigen::Matrix< double, 2, 4 > TransformDerivativeMatrix
 
typedef Eigen::Matrix< double, 4, 4 > ProductDerivativeMatrix
 
typedef Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix
 

Public Member Functions

 LinearTransform ()
 Construct an empty (identity) LinearTransform. More...
 
 LinearTransform (Matrix const &matrix)
 Construct an LinearTransform from an Eigen::Matrix. More...
 
 LinearTransform (LinearTransform const &)=default
 
 LinearTransform (LinearTransform &&)=default
 
 ~LinearTransform ()=default
 
LinearTransform operator* (LinearTransform const &other) const
 
LinearTransformoperator= (LinearTransform const &)=default
 
LinearTransformoperator= (LinearTransform &&)=default
 
LinearTransformoperator+= (LinearTransform const &other)
 
LinearTransform operator+ (LinearTransform const &other)
 
LinearTransformoperator-= (LinearTransform const &other)
 
LinearTransform operator- (LinearTransform const &other)
 
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...
 
Matrix const & getMatrix () const
 
MatrixgetMatrix ()
 
double & operator[] (int i)
 
double const & operator[] (int i) const
 
LinearTransform const invert () const
 Return the inverse transform. More...
 
double computeDeterminant () const
 Return the determinant of the 2x2 matrix. More...
 
bool isIdentity () const
 Whether the transform is a no-op. More...
 
Point2D operator() (Point2D const &p) const
 Transform a Point2D object. More...
 
Extent2D operator() (Extent2D const &p) const
 Transform a Extent2D object. More...
 
TransformDerivativeMatrix dTransform (Point2D const &input) const
 Derivative of (*this)(input) with respect to the transform elements (for Point). More...
 
TransformDerivativeMatrix dTransform (Extent2D const &input) const
 Derivative of (*this)(input) with respect to the transform elements (for Extent);. More...
 

Static Public Member Functions

static LinearTransform makeScaling (double s)
 
static LinearTransform makeScaling (double s, double t)
 
static LinearTransform makeRotation (Angle t)
 

Detailed Description

A 2D linear coordinate transformation.

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

\[ \left[\begin{array}{ c } x_f \\ y_f \end{array}\right] = \mathbf{M} \left[\begin{array}{ c } x_i \\ y_i \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 } \displaystyle\frac{\partial x_f}{\partial x_i} & \displaystyle\frac{\partial x_f}{\partial y_i} \\ \displaystyle\frac{\partial y_f}{\partial x_i} & \displaystyle\frac{\partial y_f}{\partial y_i} \end{array}\right] \]

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

Definition at line 71 of file LinearTransform.h.

Member Typedef Documentation

◆ Matrix

typedef Eigen::Matrix<double, 2, 2, Eigen::DontAlign> lsst::afw::geom::LinearTransform::Matrix

Definition at line 79 of file LinearTransform.h.

◆ ParameterVector

typedef Eigen::Matrix<double, 4, 1> lsst::afw::geom::LinearTransform::ParameterVector

Definition at line 75 of file LinearTransform.h.

◆ ProductDerivativeMatrix

typedef Eigen::Matrix<double, 4, 4> lsst::afw::geom::LinearTransform::ProductDerivativeMatrix

Definition at line 77 of file LinearTransform.h.

◆ TransformDerivativeMatrix

Definition at line 76 of file LinearTransform.h.

Member Enumeration Documentation

◆ Parameters

Constructor & Destructor Documentation

◆ LinearTransform() [1/4]

lsst::afw::geom::LinearTransform::LinearTransform ( )
inline

Construct an empty (identity) LinearTransform.

Definition at line 82 of file LinearTransform.h.

82 : _matrix(Matrix::Identity()) {}

◆ LinearTransform() [2/4]

lsst::afw::geom::LinearTransform::LinearTransform ( Matrix const &  matrix)
inlineexplicit

Construct an LinearTransform from an Eigen::Matrix.

Definition at line 85 of file LinearTransform.h.

85 : _matrix(matrix) {}

◆ LinearTransform() [3/4]

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

◆ LinearTransform() [4/4]

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

◆ ~LinearTransform()

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

Member Function Documentation

◆ computeDeterminant()

double lsst::afw::geom::LinearTransform::computeDeterminant ( ) const

Return the determinant of the 2x2 matrix.

Definition at line 56 of file LinearTransform.cc.

56  {
57  Eigen::MatrixXd const& m = getMatrix();
58  return m(0, 0) * m(1, 1) - m(0, 1) * m(1, 0);
59 }
Matrix const & getMatrix() const
int m
Definition: SpanSet.cc:44

◆ dTransform() [1/2]

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

Derivative of (*this)(input) with respect to the transform elements (for Point).

Definition at line 61 of file LinearTransform.cc.

61  {
62  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
63  r(0, XX) = input.getX();
64  r(0, XY) = input.getY();
65  r(1, YX) = input.getX();
66  r(1, YY) = input.getY();
67  return r;
68 }
Eigen::Matrix< double, 2, 4 > TransformDerivativeMatrix

◆ dTransform() [2/2]

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

Derivative of (*this)(input) with respect to the transform elements (for Extent);.

Definition at line 188 of file LinearTransform.h.

188 { return dTransform(Point2D(input)); }
Point< double, 2 > Point2D
Definition: Point.h:304
TransformDerivativeMatrix dTransform(Point2D const &input) const
Derivative of (*this)(input) with respect to the transform elements (for Point).

◆ getMatrix() [1/2]

Matrix const& lsst::afw::geom::LinearTransform::getMatrix ( ) const
inline

Definition at line 145 of file LinearTransform.h.

145 { return _matrix; }

◆ getMatrix() [2/2]

Matrix& lsst::afw::geom::LinearTransform::getMatrix ( )
inline

Definition at line 146 of file LinearTransform.h.

146 { return _matrix; }

◆ getParameterVector()

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

Return the transform matrix elements as a parameter vector.

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

Definition at line 34 of file LinearTransform.cc.

◆ invert()

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

Return the inverse transform.

Exceptions
lsst::afw::geom::SingularTransformException

Definition at line 47 of file LinearTransform.cc.

47  {
48  Eigen::FullPivLU<Matrix> lu(getMatrix());
49  if (!lu.isInvertible()) {
50  throw LSST_EXCEPT(SingularTransformException, "Could not compute LinearTransform inverse");
51  }
52  Matrix inv = lu.inverse();
53  return LinearTransform(inv);
54 }
Matrix const & getMatrix() const
LinearTransform()
Construct an empty (identity) LinearTransform.
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:47

◆ isIdentity()

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

Whether the transform is a no-op.

Definition at line 164 of file LinearTransform.h.

164 { return getMatrix().isIdentity(); }
Matrix const & getMatrix() const

◆ makeRotation()

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

Definition at line 103 of file LinearTransform.h.

103  {
104  return LinearTransform(Matrix(Eigen::Rotation2D<double>(t.asRadians())));
105  }
LinearTransform()
Construct an empty (identity) LinearTransform.
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix

◆ makeScaling() [1/2]

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

Definition at line 95 of file LinearTransform.h.

95  {
96  return LinearTransform((Matrix() << s, 0.0, 0.0, s).finished());
97  }
LinearTransform()
Construct an empty (identity) LinearTransform.
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix
solver_t * s

◆ makeScaling() [2/2]

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

Definition at line 99 of file LinearTransform.h.

99  {
100  return LinearTransform((Matrix() << s, 0.0, 0.0, t).finished());
101  }
LinearTransform()
Construct an empty (identity) LinearTransform.
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix
solver_t * s

◆ operator()() [1/2]

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

Transform a Point2D object.

This operation is equivalent to applying the LinearTransform to an lsst::afw::geom::Extent

Definition at line 172 of file LinearTransform.h.

172 { return Point2D(getMatrix() * p.asEigen()); }
Matrix const & getMatrix() const
Point< double, 2 > Point2D
Definition: Point.h:304

◆ operator()() [2/2]

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

Transform a Extent2D object.

This operation is equivalent to applying the LinearTransform to an lsst::afw::geom::Point

Definition at line 180 of file LinearTransform.h.

180 { return Extent2D(getMatrix() * p.asEigen()); }
Matrix const & getMatrix() const
Extent< double, 2 > Extent2D
Definition: Extent.h:383

◆ operator*()

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

Definition at line 91 of file LinearTransform.h.

91  {
92  return LinearTransform(getMatrix() * other.getMatrix());
93  }
Matrix const & getMatrix() const
LinearTransform()
Construct an empty (identity) LinearTransform.
ItemVariant const * other
Definition: Schema.cc:55

◆ operator+()

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

Definition at line 115 of file LinearTransform.h.

115  {
116  LinearTransform tmp(*this);
117  tmp += other;
118  return tmp;
119  }
LinearTransform()
Construct an empty (identity) LinearTransform.
ItemVariant const * other
Definition: Schema.cc:55

◆ operator+=()

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

Definition at line 110 of file LinearTransform.h.

110  {
111  _matrix += other._matrix;
112  return *this;
113  }
ItemVariant const * other
Definition: Schema.cc:55

◆ operator-()

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

Definition at line 126 of file LinearTransform.h.

126  {
127  LinearTransform tmp(*this);
128  tmp -= other;
129  return tmp;
130  }
LinearTransform()
Construct an empty (identity) LinearTransform.
ItemVariant const * other
Definition: Schema.cc:55

◆ operator-=()

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

Definition at line 121 of file LinearTransform.h.

121  {
122  _matrix -= other._matrix;
123  return *this;
124  }
ItemVariant const * other
Definition: Schema.cc:55

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

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

Definition at line 148 of file LinearTransform.h.

148 { return _matrix(i % 2, i / 2); }

◆ operator[]() [2/2]

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

Definition at line 149 of file LinearTransform.h.

149 { return const_cast<Matrix&>(_matrix)(i % 2, i / 2); }
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix

◆ setParameterVector()

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

Set the transform matrix elements from a parameter vector.

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

Definition at line 40 of file LinearTransform.cc.

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

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