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
AffineTransform.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include "Eigen/LU"
24 
25 #include <iomanip>
26 
29 
30 namespace lsst {
31 namespace afw {
32 namespace geom {
33 
36  r << (*this)[XX], (*this)[YX], (*this)[XY], (*this)[YY], (*this)[X], (*this)[Y];
37  return r;
38 }
39 
41  (*this)[XX] = vector[XX];
42  (*this)[XY] = vector[XY];
43  (*this)[X] = vector[X];
44  (*this)[YX] = vector[YX];
45  (*this)[YY] = vector[YY];
46  (*this)[Y] = vector[Y];
47 }
48 
50  Matrix r;
51  r << (*this)[XX], (*this)[XY], (*this)[X], (*this)[YX], (*this)[YY], (*this)[Y], 0.0, 0.0, 1.0;
52  return r;
53 }
54 
57  return AffineTransform(inv, -inv(getTranslation()));
58 }
59 
61  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
62  r.block<2, 4>(0, 0) = getLinear().dTransform(input);
63  r(0, X) = 1.0;
64  r(1, Y) = 1.0;
65  return r;
66 }
67 
69  TransformDerivativeMatrix r = TransformDerivativeMatrix::Zero();
70  r.block<2, 4>(0, 0) = getLinear().dTransform(input);
71  return r;
72 }
73 
75  std::ios::fmtflags flags = os.flags();
76  AffineTransform::Matrix const &matrix = transform.getMatrix();
77  int prec = os.precision(7);
78  os.setf(std::ios::fixed);
79  os << "AffineTransform([(" << std::setw(10) << matrix(0, 0) << "," << std::setw(10) << matrix(0, 1) << ","
80  << std::setw(10) << matrix(0, 2) << "),\n";
81  os << " (" << std::setw(10) << matrix(1, 0) << "," << std::setw(10) << matrix(1, 1) << ","
82  << std::setw(10) << matrix(1, 2) << "),\n";
83  os << " (" << std::setw(10) << matrix(2, 0) << "," << std::setw(10) << matrix(2, 1) << ","
84  << std::setw(10) << matrix(2, 2) << ")])";
85  os.precision(prec);
86  os.flags(flags);
87  return os;
88 }
89 
91  Point2D const &q1, Point2D const &q2, Point2D const &q3) {
92  Eigen::Matrix3d mp;
93  mp << p1.getX(), p2.getX(), p3.getX(), p1.getY(), p2.getY(), p3.getY(), 1.0, 1.0, 1.0;
94 
95  Eigen::Matrix3d mq;
96  mq << q1.getX(), q2.getX(), q3.getX(), q1.getY(), q2.getY(), q3.getY(), 1.0, 1.0, 1.0;
97 
98  Eigen::Matrix3d m = mq * mp.inverse();
99  return AffineTransform(m);
100 }
101 }
102 }
103 } // end lsst::afw::geom
T setf(T... args)
Eigen::Matrix< double, 2, 6 > TransformDerivativeMatrix
std::ostream & operator<<(std::ostream &os, lsst::afw::geom::AffineTransform const &transform)
TransformDerivativeMatrix dTransform(Point2D const &input) const
Take the derivative of (*this)(input) w.r.t the transform elements.
LinearTransform const & getLinear() const
T precision(T... args)
Matrix const getMatrix() const
Return the transform as a full 3x3 matrix.
T setw(T... args)
A 2D linear coordinate transformation.
T flags(T... args)
Eigen::Matrix< double, 6, 1 > ParameterVector
A base class for image defects.
Definition: cameraGeom.dox:3
An affine coordinate transformation consisting of a linear transformation and an offset.
TransformDerivativeMatrix dTransform(Point2D const &input) const
Derivative of (*this)(input) with respect to the transform elements (for Point).
ParameterVector const getParameterVector() const
Return the transform matrix elements as a parameter vector.
AffineTransform()
Construct an empty (identity) AffineTransform.
int m
Definition: SpanSet.cc:44
void setParameterVector(ParameterVector const &vector)
Set the transform matrix elements from a parameter vector.
AffineTransform makeAffineTransformFromTriple(Point2D const &p1, Point2D const &p2, Point2D const &p3, Point2D const &q1, Point2D const &q2, Point2D const &q3)
STL class.
AffineTransform const invert() const
Return the inverse transform.
std::ostream * os
Definition: Schema.cc:736
Extent2D const & getTranslation() const