lsst.afw  13.0-73-gb2a4e38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Transform.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 /*
3  * LSST Data Management System
4  * Copyright 2008-2017 LSST Corporation.
5  *
6  * This product includes software developed by the
7  * LSST Project (http://www.lsst.org/).
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the LSST License Statement and
20  * the GNU General Public License along with this program. If not,
21  * see <http://www.lsstcorp.org/LegalNotices/>.
22  */
23 
24 #ifndef LSST_AFW_GEOM_TRANSFORM_H
25 #define LSST_AFW_GEOM_TRANSFORM_H
26 
27 #include <memory>
28 #include <vector>
29 
30 #include "astshim.h"
31 #include "Eigen/Core"
32 #include "ndarray.h"
33 
34 #include "lsst/afw/geom/Endpoint.h"
35 
36 namespace lsst {
37 namespace afw {
38 namespace geom {
39 
63 template <class FromEndpoint, class ToEndpoint>
64 class Transform {
65 public:
66  using FromArray = typename FromEndpoint::Array;
67  using FromPoint = typename FromEndpoint::Point;
68  using ToArray = typename ToEndpoint::Array;
69  using ToPoint = typename ToEndpoint::Point;
70 
71  Transform(Transform const &) = default;
72  Transform(Transform &&) = default;
73  Transform &operator=(Transform const &) = delete;
74  Transform &operator=(Transform &&) = delete;
75 
86  explicit Transform(ast::Mapping const &mapping, bool simplify = true);
87 
108  explicit Transform(ast::FrameSet const &frameSet, bool simplify = true);
109 
110  virtual ~Transform(){};
111 
117  bool hasForward() const { return _frameSet->hasForward(); }
118 
124  bool hasInverse() const { return _frameSet->hasInverse(); }
125 
129  FromEndpoint getFromEndpoint() const { return _fromEndpoint; }
130 
134  std::shared_ptr<const ast::FrameSet> getFrameSet() const { return _frameSet; }
135 
139  ToEndpoint getToEndpoint() const { return _toEndpoint; }
140 
144  ToPoint applyForward(FromPoint const &point) const;
145 
153  ToArray applyForward(FromArray const &array) const;
154 
158  FromPoint applyInverse(ToPoint const &point) const;
159 
167  FromArray applyInverse(ToArray const &array) const;
168 
178 
198  Eigen::MatrixXd getJacobian(FromPoint const &x) const;
199 
218  template <class NextToEndpoint>
220 
221 protected:
227  explicit Transform(std::shared_ptr<ast::FrameSet> &&frameSet);
228 
229 private:
230  FromEndpoint _fromEndpoint;
231  std::shared_ptr<const ast::FrameSet> _frameSet;
232  ToEndpoint _toEndpoint;
233 };
234 
242 template <class FromEndpoint, class ToEndpoint>
243 std::ostream &operator<<(std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform);
244 
245 } // namespace geom
246 } // namespace afw
247 } // namespace lsst
248 
249 #endif
Transform & operator=(Transform const &)=delete
Transform(Transform const &)=default
Transform< ToEndpoint, FromEndpoint > getInverse() const
The inverse of this Transform.
FromEndpoint getFromEndpoint() const
Get the &quot;from&quot; endpoint.
Definition: Transform.h:129
Transform< FromEndpoint, NextToEndpoint > then(Transform< ToEndpoint, NextToEndpoint > const &next) const
Concatenate two Transforms.
bool hasInverse() const
Test if this method has an inverse transform.
Definition: Transform.h:124
bool hasForward() const
Test if this method has a forward transform.
Definition: Transform.h:117
double x
ToEndpoint getToEndpoint() const
Get the &quot;to&quot; endpoint.
Definition: Transform.h:139
std::shared_ptr< const ast::FrameSet > getFrameSet() const
Get the contained frameset.
Definition: Transform.h:134
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction (&quot;from&quot; to &quot;to&quot;)
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction (&quot;to&quot; to &quot;from&quot;)
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
Transform LSST spatial data, such as Point2D and IcrsCoord, using an AST transform.
Definition: Transform.h:64