36 lsst::geom::SingularTransformException)
69class LinearTransform final {
71 enum Parameters { XX = 0, YX = 1, XY = 2, YY = 3 };
73 typedef Eigen::Matrix<double, 4, 1> ParameterVector;
74 typedef Eigen::Matrix<double, 2, 4> TransformDerivativeMatrix;
75 typedef Eigen::Matrix<double, 4, 4> ProductDerivativeMatrix;
77 typedef Eigen::Matrix<double, 2, 2, Eigen::DontAlign> Matrix;
80 LinearTransform() noexcept : _matrix(Matrix::Identity()) {}
83 explicit LinearTransform(Matrix
const& matrix) noexcept : _matrix(matrix) {}
86 LinearTransform(LinearTransform
const& other) noexcept : _matrix(other._matrix){};
87 LinearTransform(LinearTransform&& other) noexcept : _matrix(
std::move(other._matrix)){};
88 ~LinearTransform()
noexcept =
default;
90 LinearTransform
operator*(LinearTransform
const& other)
const noexcept {
91 return LinearTransform(getMatrix() * other.getMatrix());
94 static LinearTransform makeScaling(
double s)
noexcept {
95 return LinearTransform((Matrix() << s, 0.0, 0.0, s).finished());
98 static LinearTransform makeScaling(
double s,
double t)
noexcept {
99 return LinearTransform((Matrix() << s, 0.0, 0.0, t).finished());
102 static LinearTransform makeRotation(
Angle t)
noexcept {
103 return LinearTransform(Matrix(Eigen::Rotation2D<double>(t.asRadians())));
107 LinearTransform& operator=(LinearTransform
const& other)
noexcept {
108 _matrix = other._matrix;
111 LinearTransform& operator=(LinearTransform&& other)
noexcept {
116 LinearTransform&
operator+=(LinearTransform
const& other)
noexcept {
117 _matrix += other._matrix;
121 LinearTransform
operator+(LinearTransform
const& other)
noexcept {
122 LinearTransform tmp(*
this);
127 LinearTransform&
operator-=(LinearTransform
const& other)
noexcept {
128 _matrix -= other._matrix;
132 LinearTransform
operator-(LinearTransform
const& other)
noexcept {
133 LinearTransform tmp(*
this);
143 ParameterVector
const getParameterVector()
const noexcept;
149 void setParameterVector(ParameterVector
const& vector)
noexcept;
151 Matrix
const& getMatrix()
const noexcept {
return _matrix; }
152 Matrix& getMatrix()
noexcept {
return _matrix; }
154 double& operator[](
int i) {
return _matrix(i % 2, i / 2); }
155 double const& operator[](
int i)
const {
return const_cast<Matrix&
>(_matrix)(i % 2, i / 2); }
162 LinearTransform
const inverted()
const;
167 double computeDeterminant()
const noexcept;
170 bool isIdentity()
const noexcept {
return getMatrix().isIdentity(); }
195 double applyX(
double x,
double y)
const noexcept {
return _matrix(0, 0)*x + _matrix(0, 1)*y; }
196 double applyY(
double x,
double y)
const noexcept {
return _matrix(1, 0)*x + _matrix(1, 1)*y; }
202 TransformDerivativeMatrix dTransform(
Point2D const& input)
const noexcept;
205 TransformDerivativeMatrix dTransform(
Extent2D const& input)
const noexcept {
206 return dTransform(
Point2D(input));
LSST_EXCEPTION_TYPE(SingularTransformException, lsst::pex::exceptions::RuntimeError, lsst::geom::SingularTransformException) class LinearTransform final
A 2D linear coordinate transformation.