lsst.meas.astrom  14.0-7-g0d69b06+3
SipTransform.h
Go to the documentation of this file.
1 // -*- LSST-C++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2016 LSST/AURA
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 #ifndef LSST_MEAS_ASTROM_SipTransform_INCLUDED
25 #define LSST_MEAS_ASTROM_SipTransform_INCLUDED
26 
29 #include "lsst/afw/geom/Box.h"
30 #include "lsst/afw/geom/Angle.h"
31 #include "lsst/afw/geom/SkyWcs.h"
33 
34 namespace lsst {
35 namespace afw {
36 namespace coord {
37 
38 class IcrsCoord;
39 
40 } // namespace coord
41 } // namespace afw
42 
43 namespace meas { namespace astrom {
44 
53 public:
54 
58  afw::geom::Point2D const & getPixelOrigin() const { return _pixelOrigin; }
59 
63  afw::geom::LinearTransform const & getCdMatrix() const { return _cdMatrix; }
64 
68  PolynomialTransform const & getPoly() const { return _poly; }
69 
70 protected:
71 
85  afw::geom::Point2D const & pixelOrigin,
86  afw::geom::LinearTransform const & cdMatrix,
87  PolynomialTransform const & poly
88  ) : _pixelOrigin(pixelOrigin),
89  _cdMatrix(cdMatrix),
90  _poly(poly)
91  {}
92 
93  SipTransformBase(SipTransformBase const & other) = default;
94  SipTransformBase(SipTransformBase && other) = default;
95  SipTransformBase & operator=(SipTransformBase const & other) = default;
96  SipTransformBase & operator=(SipTransformBase && other) = default;
97 
98  void swap(SipTransformBase & other) {
99  std::swap(_pixelOrigin, other._pixelOrigin);
100  std::swap(_cdMatrix, other._cdMatrix);
101  _poly.swap(other._poly);
102  }
103 
104  void transformPixelsInPlace(afw::geom::AffineTransform const & s);
105 
109 };
110 
111 
151 public:
152 
160  static SipForwardTransform convert(
161  PolynomialTransform const & poly,
162  afw::geom::Point2D const & pixelOrigin,
163  afw::geom::LinearTransform const & cdMatrix
164  );
165 
173  static SipForwardTransform convert(
174  ScaledPolynomialTransform const & scaled,
175  afw::geom::Point2D const & pixelOrigin,
176  afw::geom::LinearTransform const & cdMatrix
177  );
178 
186  static SipForwardTransform convert(ScaledPolynomialTransform const & scaled);
187 
196  afw::geom::Point2D const & pixelOrigin,
197  afw::geom::LinearTransform const & cdMatrix,
198  PolynomialTransform const & forwardSipPoly
199  ) :
200  SipTransformBase(pixelOrigin, cdMatrix, forwardSipPoly)
201  {}
202 
203  SipForwardTransform(SipForwardTransform const & other) = default;
204 
205  SipForwardTransform(SipForwardTransform && other) = default;
206 
207  SipForwardTransform & operator=(SipForwardTransform const & other) = default;
208 
209  SipForwardTransform & operator=(SipForwardTransform && other) = default;
210 
211  void swap(SipForwardTransform & other) {
212  SipTransformBase::swap(other);
213  }
214 
218  afw::geom::AffineTransform linearize(afw::geom::Point2D const & in) const;
219 
223  afw::geom::Point2D operator()(afw::geom::Point2D const & uv) const;
224 
229  SipForwardTransform transformPixels(afw::geom::AffineTransform const & s) const;
230 
231 };
232 
233 
275 public:
276 
284  static SipReverseTransform convert(
285  PolynomialTransform const & poly,
286  afw::geom::Point2D const & pixelOrigin,
287  afw::geom::LinearTransform const & cdMatrix
288  );
289 
297  static SipReverseTransform convert(
298  ScaledPolynomialTransform const & scaled,
299  afw::geom::Point2D const & pixelOrigin,
300  afw::geom::LinearTransform const & cdMatrix
301  );
302 
310  static SipReverseTransform convert(ScaledPolynomialTransform const & scaled);
311 
320  afw::geom::Point2D const & pixelOrigin,
321  afw::geom::LinearTransform const & cdMatrix,
322  PolynomialTransform const & reverseSipPoly
323  ) : SipTransformBase(pixelOrigin, cdMatrix, reverseSipPoly),
324  _cdInverse(cdMatrix.invert())
325  {}
326 
327  SipReverseTransform(SipReverseTransform const & other) = default;
328 
329  SipReverseTransform(SipReverseTransform && other) = default;
330 
331  SipReverseTransform & operator=(SipReverseTransform const & other) = default;
332 
333  SipReverseTransform & operator=(SipReverseTransform && other) = default;
334 
335  void swap(SipReverseTransform & other) {
336  SipTransformBase::swap(other);
337  std::swap(_cdInverse, other._cdInverse);
338  }
339 
343  afw::geom::AffineTransform linearize(afw::geom::Point2D const & in) const;
344 
348  afw::geom::Point2D operator()(afw::geom::Point2D const & xy) const;
349 
354  SipReverseTransform transformPixels(afw::geom::AffineTransform const & s) const;
355 
356 private:
357  friend class PolynomialTransform;
359  afw::geom::LinearTransform _cdInverse;
360 };
361 
377  SipForwardTransform const & sipForward,
378  SipReverseTransform const & sipReverse,
379  afw::coord::IcrsCoord const & skyOrigin
380 );
381 
399  afw::geom::SkyWcs const & wcs,
401 );
402 
412  afw::geom::SkyWcs const & wcs,
413  int nQuarter,
414  afw::geom::Extent2I const & dimensions
415 );
416 
417 
418 }}} // namespace lsst::meas::astrom
419 
420 #endif // !LSST_MEAS_ASTROM_SipTransform_INCLUDED
PolynomialTransform const & getPoly() const
Return the polynomial component of the transform (A,B) or (AP,BP).
Definition: SipTransform.h:68
SipForwardTransform(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &forwardSipPoly)
Construct a SipForwardTransform from its components.
Definition: SipTransform.h:195
std::shared_ptr< afw::geom::SkyWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, afw::coord::IcrsCoord const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.
T swap(T... args)
afw::geom::Point2D const & getPixelOrigin() const
Return the pixel origin (CRPIX, but zero-indexed) of the transform.
Definition: SipTransform.h:58
afw::geom::LinearTransform const & getCdMatrix() const
Return the CD matrix of the transform.
Definition: SipTransform.h:63
void swap(SipReverseTransform &other)
Definition: SipTransform.h:335
SipReverseTransform(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &reverseSipPoly)
Construct a SipReverseTransform from its components.
Definition: SipTransform.h:319
A transform that maps pixel coordinates to intermediate world coordinates according to the SIP conven...
Definition: SipTransform.h:150
Base class for SIP transform objects.
Definition: SipTransform.h:52
SipTransformBase(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &poly)
Construct a SipTransformBase from its components.
Definition: SipTransform.h:84
std::shared_ptr< afw::geom::SkyWcs > rotateWcsPixelsBy90(afw::geom::SkyWcs const &wcs, int nQuarter, afw::geom::Extent2I const &dimensions)
Return a new SkyWcs that represents a rotation of the image it corresponds to about the image&#39;s cente...
A 2-d coordinate transform represented by a lazy composition of an AffineTransform, a PolynomialTransform, and another AffineTransform.
afw::geom::LinearTransform _cdMatrix
Definition: SipTransform.h:107
A transform that maps intermediate world coordinates to pixel coordinates according to the SIP conven...
Definition: SipTransform.h:274
void swap(SipForwardTransform &other)
Definition: SipTransform.h:211
void swap(SipTransformBase &other)
Definition: SipTransform.h:98
std::shared_ptr< afw::geom::SkyWcs > transformWcsPixels(afw::geom::SkyWcs const &wcs, afw::geom::AffineTransform const &s)
Create a new SkyWcs whose pixel coordinate system has been transformed via an affine transform...
A 2-d coordinate transform represented by a pair of standard polynomials (one for each coordinate)...