LSSTApplications  21.0.0+1b62c9342b,21.0.0+45a059f35e,21.0.0-1-ga51b5d4+ceb9cf20a3,21.0.0-2-g103fe59+4d13aff7ba,21.0.0-2-g1367e85+571a348718,21.0.0-2-g2909d54+45a059f35e,21.0.0-2-g45278ab+1b62c9342b,21.0.0-2-g4bc9b9f+ebfe466dad,21.0.0-2-g5242d73+571a348718,21.0.0-2-g54e2caa+07cebfb09d,21.0.0-2-g66bcc37+0b2c5d3971,21.0.0-2-g7f82c8f+08f1f55c36,21.0.0-2-g8dde007+5d1b9cb3f5,21.0.0-2-g8f08a60+73884b2cf5,21.0.0-2-ga326454+08f1f55c36,21.0.0-2-ga63a54e+458e82fbcd,21.0.0-2-gc738bc1+8c4731df06,21.0.0-2-gde069b7+5a8f2956b8,21.0.0-2-ge17e5af+571a348718,21.0.0-2-ge712728+cfa36ee5f9,21.0.0-2-gecfae73+e597808034,21.0.0-2-gfc62afb+571a348718,21.0.0-20-g4449a12+6d1341e0f3,21.0.0-22-gf0532904+1cd928f0c5,21.0.0-3-g4c5b185+c3794955c6,21.0.0-3-g6d51c4a+0b2c5d3971,21.0.0-3-g8076721+5adeb471db,21.0.0-3-gaa929c8+01f4b7cfca,21.0.0-3-gd222c45+afc8332dbe,21.0.0-4-g1383c07+0b2c5d3971,21.0.0-4-g3300ddd+1b62c9342b,21.0.0-4-g5873dc9+9a92674037,21.0.0-4-g8a80011+bd904b6426,21.0.0-5-gcff38f6+844b7f7b93,21.0.0-6-g463d161+18af5fb57b,21.0.0-6-gd3283ba+01f4b7cfca,21.0.0-8-g19111d86+8234efb485,21.0.0-9-g7bed000b9+c7d3cce47e,w.2021.04
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | List of all members
lsst::geom::LinearTransform Class Referencefinal

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

Static Public Member Functions

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

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 69 of file LinearTransform.h.

Member Typedef Documentation

◆ Matrix

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

Definition at line 77 of file LinearTransform.h.

◆ ParameterVector

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

Definition at line 73 of file LinearTransform.h.

◆ ProductDerivativeMatrix

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

Definition at line 75 of file LinearTransform.h.

◆ TransformDerivativeMatrix

typedef Eigen::Matrix<double, 2, 4> lsst::geom::LinearTransform::TransformDerivativeMatrix

Definition at line 74 of file LinearTransform.h.

Member Enumeration Documentation

◆ Parameters

Enumerator
XX 
YX 
XY 
YY 

Definition at line 71 of file LinearTransform.h.

71 { XX = 0, YX = 1, XY = 2, YY = 3 };

Constructor & Destructor Documentation

◆ LinearTransform() [1/4]

lsst::geom::LinearTransform::LinearTransform ( )
inlinenoexcept

Construct an empty (identity) LinearTransform.

Definition at line 80 of file LinearTransform.h.

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

◆ LinearTransform() [2/4]

lsst::geom::LinearTransform::LinearTransform ( Matrix const &  matrix)
inlineexplicitnoexcept

Construct an LinearTransform from an Eigen::Matrix.

Definition at line 83 of file LinearTransform.h.

83 : _matrix(matrix) {}

◆ LinearTransform() [3/4]

lsst::geom::LinearTransform::LinearTransform ( LinearTransform const &  other)
inlinenoexcept

Definition at line 86 of file LinearTransform.h.

86 : _matrix(other._matrix){};

◆ LinearTransform() [4/4]

lsst::geom::LinearTransform::LinearTransform ( LinearTransform &&  other)
inlinenoexcept

Definition at line 87 of file LinearTransform.h.

87 : _matrix(std::move(other._matrix)){};

◆ ~LinearTransform()

lsst::geom::LinearTransform::~LinearTransform ( )
defaultnoexcept

Member Function Documentation

◆ applyX()

double lsst::geom::LinearTransform::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 195 of file LinearTransform.h.

195 { return _matrix(0, 0)*x + _matrix(0, 1)*y; }

◆ applyY()

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

Definition at line 196 of file LinearTransform.h.

196 { return _matrix(1, 0)*x + _matrix(1, 1)*y; }

◆ computeDeterminant()

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

Return the determinant of the 2x2 matrix.

Definition at line 54 of file LinearTransform.cc.

54 { return getMatrix().determinant(); }

◆ dTransform() [1/2]

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

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

Definition at line 205 of file LinearTransform.h.

205  {
206  return dTransform(Point2D(input));
207  }

◆ dTransform() [2/2]

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

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

Definition at line 56 of file LinearTransform.cc.

56  {
57  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
58  r(0, XX) = input.getX();
59  r(0, XY) = input.getY();
60  r(1, YX) = input.getX();
61  r(1, YY) = input.getY();
62  return r;
63 }

◆ getMatrix() [1/2]

Matrix const& lsst::geom::LinearTransform::getMatrix ( ) const
inlinenoexcept

Definition at line 151 of file LinearTransform.h.

151 { return _matrix; }

◆ getMatrix() [2/2]

Matrix& lsst::geom::LinearTransform::getMatrix ( )
inlinenoexcept

Definition at line 152 of file LinearTransform.h.

152 { return _matrix; }

◆ getParameterVector()

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

Return the transform matrix elements as a parameter vector.

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

Definition at line 32 of file LinearTransform.cc.

32  {
34  r << (*this)[XX], (*this)[YX], (*this)[XY], (*this)[YY];
35  return r;
36 }

◆ inverted()

LinearTransform const lsst::geom::LinearTransform::inverted ( ) const

Return the inverse transform.

Exceptions
lsst::geom::SingularTransformExceptionif not invertible

Definition at line 45 of file LinearTransform.cc.

45  {
46  Eigen::FullPivLU<Matrix> lu(getMatrix());
47  if (!lu.isInvertible()) {
48  throw LSST_EXCEPT(SingularTransformException, "Could not compute LinearTransform inverse");
49  }
50  Matrix inv = lu.inverse();
51  return LinearTransform(inv);
52 }

◆ isIdentity()

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

Whether the transform is a no-op.

Definition at line 170 of file LinearTransform.h.

170 { return getMatrix().isIdentity(); }

◆ makeRotation()

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

Definition at line 102 of file LinearTransform.h.

102  {
103  return LinearTransform(Matrix(Eigen::Rotation2D<double>(t.asRadians())));
104  }

◆ makeScaling() [1/2]

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

Definition at line 94 of file LinearTransform.h.

94  {
95  return LinearTransform((Matrix() << s, 0.0, 0.0, s).finished());
96  }

◆ makeScaling() [2/2]

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

Definition at line 98 of file LinearTransform.h.

98  {
99  return LinearTransform((Matrix() << s, 0.0, 0.0, t).finished());
100  }

◆ operator()() [1/2]

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

Transform a Extent2D object.

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

Definition at line 186 of file LinearTransform.h.

186 { return Extent2D(getMatrix() * p.asEigen()); }

◆ operator()() [2/2]

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

Transform a Point2D object.

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

Definition at line 178 of file LinearTransform.h.

178 { return Point2D(getMatrix() * p.asEigen()); }

◆ operator*()

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

Definition at line 90 of file LinearTransform.h.

90  {
91  return LinearTransform(getMatrix() * other.getMatrix());
92  }

◆ operator+()

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

Definition at line 121 of file LinearTransform.h.

121  {
122  LinearTransform tmp(*this);
123  tmp += other;
124  return tmp;
125  }

◆ operator+=()

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

Definition at line 116 of file LinearTransform.h.

116  {
117  _matrix += other._matrix;
118  return *this;
119  }

◆ operator-()

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

Definition at line 132 of file LinearTransform.h.

132  {
133  LinearTransform tmp(*this);
134  tmp -= other;
135  return tmp;
136  }

◆ operator-=()

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

Definition at line 127 of file LinearTransform.h.

127  {
128  _matrix -= other._matrix;
129  return *this;
130  }

◆ operator=() [1/2]

LinearTransform& lsst::geom::LinearTransform::operator= ( LinearTransform &&  other)
inlinenoexcept

Definition at line 111 of file LinearTransform.h.

111  {
112  _matrix = std::move(other._matrix);
113  return *this;
114  }

◆ operator=() [2/2]

LinearTransform& lsst::geom::LinearTransform::operator= ( LinearTransform const &  other)
inlinenoexcept

Definition at line 107 of file LinearTransform.h.

107  {
108  _matrix = other._matrix;
109  return *this;
110  }

◆ operator[]() [1/2]

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

Definition at line 154 of file LinearTransform.h.

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

◆ operator[]() [2/2]

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

Definition at line 155 of file LinearTransform.h.

155 { return const_cast<Matrix&>(_matrix)(i % 2, i / 2); }

◆ setParameterVector()

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

Set the transform matrix elements from a parameter vector.

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

Definition at line 38 of file LinearTransform.cc.

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

The documentation for this class was generated from the following files:
y
int y
Definition: SpanSet.cc:49
lsst::geom::LinearTransform::XX
@ XX
Definition: LinearTransform.h:71
std::move
T move(T... args)
lsst::geom::Point2D
Point< double, 2 > Point2D
Definition: Point.h:324
lsst::geom::LinearTransform::XY
@ XY
Definition: LinearTransform.h:71
lsst::geom::LinearTransform::YX
@ YX
Definition: LinearTransform.h:71
x
double x
Definition: ChebyshevBoundedField.cc:277
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::geom::LinearTransform::YY
@ YY
Definition: LinearTransform.h:71
lsst::geom::LinearTransform::LinearTransform
LinearTransform() noexcept
Construct an empty (identity) LinearTransform.
Definition: LinearTransform.h:80
lsst::geom::LinearTransform::ParameterVector
Eigen::Matrix< double, 4, 1 > ParameterVector
Definition: LinearTransform.h:73
lsst::geom::LinearTransform::getMatrix
Matrix const & getMatrix() const noexcept
Definition: LinearTransform.h:151
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::geom::LinearTransform::TransformDerivativeMatrix
Eigen::Matrix< double, 2, 4 > TransformDerivativeMatrix
Definition: LinearTransform.h:74
lsst::geom::Extent2D
Extent< double, 2 > Extent2D
Definition: Extent.h:400
lsst::geom::LinearTransform::Matrix
Eigen::Matrix< double, 2, 2, Eigen::DontAlign > Matrix
Definition: LinearTransform.h:77
lsst::geom::LinearTransform::dTransform
TransformDerivativeMatrix dTransform(Point2D const &input) const noexcept
Derivative of (*this)(input) with respect to the transform elements (for Point).
Definition: LinearTransform.cc:56