lsst.afw  14.0-25-g0e8fc950e+5
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 
230 
237 
240 
253  virtual void writeStream(std::ostream & os) const;
254 
256  virtual std::string writeString() const;
257 
258 protected:
265 
266 private:
267  FromEndpoint _fromEndpoint;
269  ToEndpoint _toEndpoint;
270 };
271 
279 template <class FromEndpoint, class ToEndpoint>
280 std::ostream &operator<<(std::ostream &os, Transform<FromEndpoint, ToEndpoint> const &transform);
281 
282 // typedefs for the most common transforms; names match Python names
283 
287 
288 } // namespace geom
289 } // namespace afw
290 } // namespace lsst
291 
292 #endif
ToEndpoint getToEndpoint() const
Get the "to" endpoint.
Definition: Transform.h:139
static Transform< FromEndpoint, ToEndpoint > readStream(std::istream &is)
Deserialize a Transform of this type from an input stream.
FromEndpoint getFromEndpoint() const
Get the "from" endpoint.
Definition: Transform.h:129
bool hasInverse() const
Test if this method has an inverse transform.
Definition: Transform.h:124
Transform & operator=(Transform const &)=delete
std::shared_ptr< const ast::FrameSet > getFrameSet() const
Get the contained frameset.
Definition: Transform.h:134
Transform(Transform const &)=default
Transform< FromEndpoint, NextToEndpoint > then(Transform< ToEndpoint, NextToEndpoint > const &next) const
Concatenate two Transforms.
STL class.
static std::string getShortClassName()
Return a short version of the class name with no punctuation.
virtual std::string writeString() const
Serialize this Transform to a string, using the same format as writeStream.
ToPoint applyForward(FromPoint const &point) const
Transform one point in the forward direction ("from" to "to")
STL class.
bool hasForward() const
Test if this method has a forward transform.
Definition: Transform.h:117
A base class for image defects.
virtual void writeStream(std::ostream &os) const
Serialize this Transform to an output stream.
table::Key< table::Array< std::uint8_t > > frameSet
double x
Eigen::MatrixXd getJacobian(FromPoint const &x) const
The Jacobian matrix of this Transform.
static Transform< FromEndpoint, ToEndpoint > readString(std::string &str)
Deserialize a Transform of this type from a string, using the same format as readStream.
Transform< ToEndpoint, FromEndpoint > getInverse() const
The inverse of this Transform.
STL class.
FromPoint applyInverse(ToPoint const &point) const
Transform one point in the inverse direction ("to" to "from")
Transform LSST spatial data, such as Point2D and IcrsCoord, using an AST transform.
Definition: Transform.h:64