lsst.meas.astrom  13.0-14-g9415442+18
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Groups Pages
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 
27 #include "lsst/afw/geom/LinearTransform.h"
28 #include "lsst/afw/geom/AffineTransform.h"
29 #include "lsst/afw/geom/Box.h"
30 #include "lsst/afw/geom/Angle.h"
32 
33 
34 namespace lsst { namespace afw { namespace image {
35 
36 class TanWcs;
37 
38 } // namespace image
39 
40 namespace coord {
41 
42 class Coord;
43 
44 } // namespace coord
45 
46 } // namespace afw
47 
48 namespace meas { namespace astrom {
49 
58 public:
59 
63  afw::geom::Point2D const & getPixelOrigin() const { return _pixelOrigin; }
64 
68  afw::geom::LinearTransform const & getCDMatrix() const { return _cdMatrix; }
69 
73  PolynomialTransform const & getPoly() const { return _poly; }
74 
75 protected:
76 
90  afw::geom::Point2D const & pixelOrigin,
91  afw::geom::LinearTransform const & cdMatrix,
92  PolynomialTransform const & poly
93  ) : _pixelOrigin(pixelOrigin),
94  _cdMatrix(cdMatrix),
95  _poly(poly)
96  {}
97 
98  SipTransformBase(SipTransformBase const & other) = default;
99  SipTransformBase(SipTransformBase && other) = default;
100  SipTransformBase & operator=(SipTransformBase const & other) = default;
101  SipTransformBase & operator=(SipTransformBase && other) = default;
102 
103  void swap(SipTransformBase & other) {
104  std::swap(_pixelOrigin, other._pixelOrigin);
105  std::swap(_cdMatrix, other._cdMatrix);
106  _poly.swap(other._poly);
107  }
108 
109  void transformPixelsInPlace(afw::geom::AffineTransform const & s);
110 
111  afw::geom::Point2D _pixelOrigin;
112  afw::geom::LinearTransform _cdMatrix;
114 };
115 
116 
156 public:
157 
166  PolynomialTransform const & poly,
167  afw::geom::Point2D const & pixelOrigin,
168  afw::geom::LinearTransform const & cdMatrix
169  );
170 
179  ScaledPolynomialTransform const & scaled,
180  afw::geom::Point2D const & pixelOrigin,
181  afw::geom::LinearTransform const & cdMatrix
182  );
183 
192 
196  static SipForwardTransform extract(afw::image::TanWcs const & wcs);
197 
206  afw::geom::Point2D const & pixelOrigin,
207  afw::geom::LinearTransform const & cdMatrix,
208  PolynomialTransform const & forwardSipPoly
209  ) :
210  SipTransformBase(pixelOrigin, cdMatrix, forwardSipPoly)
211  {}
212 
213  SipForwardTransform(SipForwardTransform const & other) = default;
214 
215  SipForwardTransform(SipForwardTransform && other) = default;
216 
217  SipForwardTransform & operator=(SipForwardTransform const & other) = default;
218 
219  SipForwardTransform & operator=(SipForwardTransform && other) = default;
220 
221  void swap(SipForwardTransform & other) {
222  SipTransformBase::swap(other);
223  }
224 
228  afw::geom::AffineTransform linearize(afw::geom::Point2D const & in) const;
229 
233  afw::geom::Point2D operator()(afw::geom::Point2D const & uv) const;
234 
239  SipForwardTransform transformPixels(afw::geom::AffineTransform const & s) const;
240 
241 };
242 
243 
285 public:
286 
295  PolynomialTransform const & poly,
296  afw::geom::Point2D const & pixelOrigin,
297  afw::geom::LinearTransform const & cdMatrix
298  );
299 
308  ScaledPolynomialTransform const & scaled,
309  afw::geom::Point2D const & pixelOrigin,
310  afw::geom::LinearTransform const & cdMatrix
311  );
312 
321 
325  static SipReverseTransform extract(afw::image::TanWcs const & wcs);
326 
335  afw::geom::Point2D const & pixelOrigin,
336  afw::geom::LinearTransform const & cdMatrix,
337  PolynomialTransform const & reverseSipPoly
338  ) : SipTransformBase(pixelOrigin, cdMatrix, reverseSipPoly),
339  _cdInverse(cdMatrix.invert())
340  {}
341 
342  SipReverseTransform(SipReverseTransform const & other) = default;
343 
344  SipReverseTransform(SipReverseTransform && other) = default;
345 
346  SipReverseTransform & operator=(SipReverseTransform const & other) = default;
347 
348  SipReverseTransform & operator=(SipReverseTransform && other) = default;
349 
350  void swap(SipReverseTransform & other) {
351  SipTransformBase::swap(other);
352  std::swap(_cdInverse, other._cdInverse);
353  }
354 
358  afw::geom::AffineTransform linearize(afw::geom::Point2D const & in) const;
359 
363  afw::geom::Point2D operator()(afw::geom::Point2D const & xy) const;
364 
369  SipReverseTransform transformPixels(afw::geom::AffineTransform const & s) const;
370 
371 private:
372  friend class PolynomialTransform;
374  afw::geom::LinearTransform _cdInverse;
375 };
376 
391 std::shared_ptr<afw::image::TanWcs> makeWcs(
392  SipForwardTransform const & sipForward,
393  SipReverseTransform const & sipReverse,
394  afw::coord::Coord const & skyOrigin
395 );
396 
413 std::shared_ptr<afw::image::TanWcs> transformWcsPixels(
414  afw::image::TanWcs const & wcs,
415  afw::geom::AffineTransform const & s
416 );
417 
426 std::shared_ptr<afw::image::TanWcs> rotateWcsPixelsBy90(
427  afw::image::TanWcs const & wcs,
428  int nQuarter,
429  afw::geom::Extent2I const & dimensions
430 );
431 
432 
433 }}} // namespace lsst::meas::astrom
434 
435 #endif // !LSST_MEAS_ASTROM_SipTransform_INCLUDED
SipForwardTransform(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &forwardSipPoly)
Construct a SipForwardTransform from its components.
Definition: SipTransform.h:205
static SipForwardTransform convert(PolynomialTransform const &poly, afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix)
Convert a PolynomialTransform to an equivalent SipForwardTransform.
Definition: SipTransform.cc:45
std::shared_ptr< afw::image::TanWcs > transformWcsPixels(afw::image::TanWcs const &wcs, afw::geom::AffineTransform const &s)
Create a new TanWcs whose pixel coordinate system has been transformed via an affine transform...
afw::geom::AffineTransform linearize(afw::geom::Point2D const &in) const
Return an approximate affine transform at the given point.
SipForwardTransform & operator=(SipForwardTransform const &other)=default
void swap(SipReverseTransform &other)
Definition: SipTransform.h:350
afw::geom::Point2D operator()(afw::geom::Point2D const &xy) const
Apply the transform to a point.
SipReverseTransform(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &reverseSipPoly)
Construct a SipReverseTransform from its components.
Definition: SipTransform.h:334
static SipReverseTransform extract(afw::image::TanWcs const &wcs)
Extract the reverse transform from a TanWcs.
SipForwardTransform transformPixels(afw::geom::AffineTransform const &s) const
Return a new forward SIP transform that includes a transformation of the pixel coordinate system by t...
A transform that maps pixel coordinates to intermediate world coordinates according to the SIP conven...
Definition: SipTransform.h:155
std::shared_ptr< afw::image::TanWcs > rotateWcsPixelsBy90(afw::image::TanWcs const &wcs, int nQuarter, afw::geom::Extent2I const &dimensions)
Return a new TanWcs that represents a rotation of the image it corresponds to about the image&#39;s cente...
afw::geom::Point2D const & getPixelOrigin() const
Return the pixel origin (CRPIX) of the transform.
Definition: SipTransform.h:63
void swap(PolynomialTransform &other)
Lightweight swap.
SipReverseTransform & operator=(SipReverseTransform const &other)=default
Base class for SIP transform objects.
Definition: SipTransform.h:57
static SipForwardTransform extract(afw::image::TanWcs const &wcs)
Extract the reverse transform from a TanWcs.
Definition: SipTransform.cc:90
PolynomialTransform const & getPoly() const
Return the polynomial component of the transform (A,B) or (AP,BP).
Definition: SipTransform.h:73
afw::geom::AffineTransform linearize(afw::geom::Point2D const &in) const
Return an approximate affine transform at the given point.
SipTransformBase(afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix, PolynomialTransform const &poly)
Construct a SipTransformBase from its components.
Definition: SipTransform.h:89
std::shared_ptr< afw::image::TanWcs > makeWcs(SipForwardTransform const &sipForward, SipReverseTransform const &sipReverse, afw::coord::Coord const &skyOrigin)
Create a new TAN SIP Wcs from a pair of SIP transforms and the sky origin.
A 2-d coordinate transform represented by a lazy composition of an AffineTransform, a PolynomialTransform, and another AffineTransform.
afw::geom::Point2D operator()(afw::geom::Point2D const &uv) const
Apply the transform to a point.
afw::geom::LinearTransform _cdMatrix
Definition: SipTransform.h:112
A transform that maps intermediate world coordinates to pixel coordinates according to the SIP conven...
Definition: SipTransform.h:284
static SipReverseTransform convert(PolynomialTransform const &poly, afw::geom::Point2D const &pixelOrigin, afw::geom::LinearTransform const &cdMatrix)
Convert a PolynomialTransform to an equivalent SipReverseTransform.
void transformPixelsInPlace(afw::geom::AffineTransform const &s)
Definition: SipTransform.cc:33
void swap(SipForwardTransform &other)
Definition: SipTransform.h:221
afw::geom::LinearTransform const & getCDMatrix() const
Return the CD matrix of the transform.
Definition: SipTransform.h:68
void swap(SipTransformBase &other)
Definition: SipTransform.h:103
SipReverseTransform transformPixels(afw::geom::AffineTransform const &s) const
Return a new reverse SIP transform that includes a transformation of the pixel coordinate system by t...
SipTransformBase & operator=(SipTransformBase const &other)=default
A 2-d coordinate transform represented by a pair of standard polynomials (one for each coordinate)...