lsst.afw  20.0.0-9-g61a2a9a3d+14f89e4eca
BaseCore.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
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 
25 #ifndef LSST_AFW_GEOM_ELLIPSES_BaseCore_h_INCLUDED
26 #define LSST_AFW_GEOM_ELLIPSES_BaseCore_h_INCLUDED
27 
28 /*
29  * Forward declarations, typedefs, and definitions for BaseCore.
30  *
31  * Note: do not include directly; use the main ellipse header file.
32  */
33 
34 #include <memory>
35 
36 #include "Eigen/Core"
37 
38 #include "lsst/pex/exceptions.h"
40 
41 namespace lsst {
42 namespace afw {
43 namespace geom {
44 namespace ellipses {
45 
46 class Parametric;
47 
55 class BaseCore {
56 public:
57  class Transformer;
58  class GridTransform;
59  class Convolution;
60  template <typename Output>
61  struct Converter;
62 
63  typedef Eigen::Vector3d ParameterVector;
64  typedef Eigen::Matrix3d Jacobian;
65 
67 
68  static std::shared_ptr<BaseCore> make(std::string const& name, ParameterVector const& parameters);
69 
70  static std::shared_ptr<BaseCore> make(std::string const& name, double v1, double v2, double v3);
71 
73 
75 
77 
79  virtual std::string getName() const = 0;
80 
82  std::shared_ptr<BaseCore> clone() const { return _clone(); }
83 
88  virtual void normalize() = 0;
89 
91  void grow(double buffer);
92 
94  void scale(double factor);
95 
97  double getArea() const;
98 
105  double getDeterminantRadius() const;
106 
112  double getTraceRadius() const;
113 
125 
132  GridTransform const getGridTransform() const;
133 
139  Convolution const convolve(BaseCore const& other) const;
141 
144 
145  virtual void readParameters(double const* iter) = 0;
146 
147  virtual void writeParameters(double* iter) const = 0;
148 
150  ParameterVector const getParameterVector() const;
151 
153  void setParameterVector(ParameterVector const& vector);
154 
160  bool operator==(BaseCore const& other) const;
161 
167  bool operator!=(BaseCore const& other) const { return !operator==(other); }
168 
174  BaseCore& operator=(BaseCore const& other);
176 
178  Jacobian dAssign(BaseCore const& other);
179 
183  template <typename Output>
184  Converter<Output> as() const;
185 
186  virtual ~BaseCore() = default;
187 
188 protected:
189  friend class Parametric;
190 
191  BaseCore() = default;
192 
193  static void registerSubclass(std::shared_ptr<BaseCore> const& example);
194 
195  template <typename T>
196  struct Registrar {
197  Registrar() { registerSubclass(std::make_shared<T>()); }
198  };
199 
200  virtual std::shared_ptr<BaseCore> _clone() const = 0;
201 
202  static void _assignQuadrupoleToAxes(double ixx, double iyy, double ixy, double& a, double& b,
203  double& theta);
204 
205  static Jacobian _dAssignQuadrupoleToAxes(double ixx, double iyy, double ixy, double& a, double& b,
206  double& theta);
207 
208  static void _assignAxesToQuadrupole(double a, double b, double theta, double& ixx, double& iyy,
209  double& ixy);
210 
211  static Jacobian _dAssignAxesToQuadrupole(double a, double b, double theta, double& ixx, double& iyy,
212  double& ixy);
213 
214  virtual void _assignToQuadrupole(double& ixx, double& iyy, double& ixy) const = 0;
215  virtual void _assignFromQuadrupole(double ixx, double iyy, double ixy) = 0;
216 
217  virtual void _assignToAxes(double& a, double& b, double& theta) const = 0;
218  virtual void _assignFromAxes(double a, double b, double theta) = 0;
219 
220  virtual Jacobian _dAssignToQuadrupole(double& ixx, double& iyy, double& ixy) const = 0;
221  virtual Jacobian _dAssignFromQuadrupole(double ixx, double iyy, double ixy) = 0;
222 
223  virtual Jacobian _dAssignToAxes(double& a, double& b, double& theta) const = 0;
224  virtual Jacobian _dAssignFromAxes(double a, double b, double theta) = 0;
225 };
226 
227 template <typename Output>
228 struct BaseCore::Converter {
229  BaseCore const& input;
230 
231  explicit Converter(BaseCore const& input_) : input(input_) {}
232 
233  operator Output() const { return Output(input); }
235 };
236 
237 template <typename Output>
239  return Converter<Output>(*this);
240 }
241 } // namespace ellipses
242 } // namespace geom
243 } // namespace afw
244 } // namespace lsst
245 
246 #endif // !LSST_AFW_GEOM_ELLIPSES_BaseCore_h_INCLUDED
lsst::afw::geom::ellipses::BaseCore::as
Converter< Output > as() const
Convert this to the core type specified as a template parameter.
Definition: BaseCore.h:238
lsst::afw::geom::ellipses::BaseCore::Transformer
A temporary-only expression object for ellipse core transformations.
Definition: Transformer.h:49
lsst::afw::geom::ellipses::BaseCore::_assignToQuadrupole
virtual void _assignToQuadrupole(double &ixx, double &iyy, double &ixy) const =0
Return the size of the bounding box for the ellipse core.
std::string
STL class.
std::shared_ptr
STL class.
ellipses
lsst::afw::geom::ellipses::BaseCore::Converter::copy
std::shared_ptr< Output > copy() const
Definition: BaseCore.h:234
lsst::afw::geom::ellipses::BaseCore::BaseCore
BaseCore()=default
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::writeParameters
virtual void writeParameters(double *iter) const =0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::getArea
double getArea() const
Return the area of the ellipse core.
Definition: BaseCore.cc:112
lsst::afw::geom::ellipses::BaseCore::_dAssignAxesToQuadrupole
static Jacobian _dAssignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:232
LinearTransform.h
lsst::geom::LinearTransform
lsst::afw::geom::ellipses::BaseCore::Registrar::Registrar
Registrar()
Definition: BaseCore.h:197
lsst::afw::geom::ellipses::BaseCore::Converter::input
BaseCore const & input
Definition: BaseCore.h:229
lsst::afw::geom::ellipses::BaseCore::make
static std::shared_ptr< BaseCore > make(std::string const &name)
Definition: BaseCore.cc:56
lsst::afw::geom::ellipses::BaseCore::grow
void grow(double buffer)
Increase the major and minor radii of the ellipse core by the given buffer.
Definition: BaseCore.cc:96
lsst::afw::geom::ellipses::BaseCore::computeDimensions
lsst::geom::Extent2D computeDimensions() const
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:130
lsst::afw::geom.transform.transformContinued.name
string name
Definition: transformContinued.py:32
lsst::afw::geom::ellipses::BaseCore::getDeterminantRadius
double getDeterminantRadius() const
Return the radius defined as the 4th root of the determinant of the quadrupole matrix.
Definition: BaseCore.cc:118
lsst::afw::geom::ellipses::BaseCore::getParameterVector
ParameterVector const getParameterVector() const
Return the core parameters as a vector.
Definition: BaseCore.cc:144
lsst::afw::geom::ellipses::BaseCore::_clone
virtual std::shared_ptr< BaseCore > _clone() const =0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::normalize
virtual void normalize()=0
Put the parameters into a "standard form", and throw InvalidParameterError if they cannot be normaliz...
lsst::afw::geom::ellipses::BaseCore::operator==
bool operator==(BaseCore const &other) const
Compare two ellipse cores for equality.
Definition: BaseCore.cc:152
lsst::afw::geom::ellipses::BaseCore::_assignToAxes
virtual void _assignToAxes(double &a, double &b, double &theta) const =0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::setParameterVector
void setParameterVector(ParameterVector const &vector)
Set the core parameters from a vector.
Definition: BaseCore.cc:150
lsst::afw::geom::ellipses::BaseCore::Registrar
Definition: BaseCore.h:196
lsst::afw::geom::ellipses::BaseCore::~BaseCore
virtual ~BaseCore()=default
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size.
Definition: BaseCore.h:55
lsst::afw::geom::ellipses::BaseCore::_dAssignQuadrupoleToAxes
static Jacobian _dAssignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:194
lsst::afw::geom::ellipses::BaseCore::readParameters
virtual void readParameters(double const *iter)=0
Return the size of the bounding box for the ellipse core.
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::geom::ellipses::BaseCore::_assignFromQuadrupole
virtual void _assignFromQuadrupole(double ixx, double iyy, double ixy)=0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::ParameterVector
Eigen::Vector3d ParameterVector
Parameter vector type.
Definition: BaseCore.h:61
lsst::afw::geom::ellipses::BaseCore::convolve
Convolution convolve(BaseCore const &other)
Return the size of the bounding box for the ellipse core.
Definition: Convolution.h:93
lsst::afw::geom::ellipses::BaseCore::_dAssignToQuadrupole
virtual Jacobian _dAssignToQuadrupole(double &ixx, double &iyy, double &ixy) const =0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::dAssign
Jacobian dAssign(BaseCore const &other)
Assign other to this and return the derivative of the conversion, d(this)/d(other).
Definition: BaseCore.cc:169
lsst::afw::geom::ellipses::BaseCore::getTraceRadius
double getTraceRadius() const
Return the radius defined as the square root of one half the trace of the quadrupole matrix.
Definition: BaseCore.cc:124
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
lsst::afw::geom::ellipses::Parametric
A functor that returns points on the boundary of the ellipse as a function of a parameter that runs b...
Definition: Parametric.h:39
lsst::afw::geom::ellipses::BaseCore::registerSubclass
static void registerSubclass(std::shared_ptr< BaseCore > const &example)
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:92
lsst
A base class for image defects.
exceptions.h
lsst::afw::geom::ellipses::BaseCore::_dAssignFromQuadrupole
virtual Jacobian _dAssignFromQuadrupole(double ixx, double iyy, double ixy)=0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::Jacobian
Eigen::Matrix3d Jacobian
Parameter Jacobian matrix type.
Definition: BaseCore.h:64
lsst::afw::geom::ellipses::BaseCore::Converter::Converter
Converter(BaseCore const &input_)
Definition: BaseCore.h:231
lsst::afw::geom::ellipses::BaseCore::_dAssignToAxes
virtual Jacobian _dAssignToAxes(double &a, double &b, double &theta) const =0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::_assignAxesToQuadrupole
static void _assignAxesToQuadrupole(double a, double b, double theta, double &ixx, double &iyy, double &ixy)
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:219
a
table::Key< int > a
Definition: TransmissionCurve.cc:466
lsst::afw::geom::ellipses::BaseCore::getName
virtual std::string getName() const =0
Return a string that identifies this parametrization.
lsst::afw::geom::ellipses::BaseCore::transform
Transformer transform(lsst::geom::LinearTransform const &transform)
Return the transform that maps the ellipse to the unit circle.
Definition: Transformer.h:116
lsst::afw::geom::ellipses::BaseCore::Converter
Definition: BaseCore.h:61
lsst::afw::geom::ellipses::BaseCore::operator!=
bool operator!=(BaseCore const &other) const
Compare two ellipse cores for inequality.
Definition: BaseCore.h:167
lsst::afw::geom::ellipses::BaseCore::getGridTransform
GridTransform const getGridTransform() const
Return the transform that maps the ellipse to the unit circle.
Definition: GridTransform.h:120
lsst::afw::geom::ellipses::BaseCore::GridTransform
A temporary-only expression object representing an lsst::geom::LinearTransform that maps the ellipse ...
Definition: GridTransform.h:48
lsst::afw::geom::ellipses::BaseCore::operator=
BaseCore & operator=(BaseCore const &other)
Set the parameters of this ellipse core from another.
Definition: BaseCore.cc:156
lsst::afw::geom::ellipses::BaseCore::clone
std::shared_ptr< BaseCore > clone() const
Deep-copy the Core.
Definition: BaseCore.h:82
lsst::afw::geom::ellipses::BaseCore::_dAssignFromAxes
virtual Jacobian _dAssignFromAxes(double a, double b, double theta)=0
Return the size of the bounding box for the ellipse core.
Extent< double, 2 >
lsst::afw::geom::ellipses::BaseCore::_assignFromAxes
virtual void _assignFromAxes(double a, double b, double theta)=0
Return the size of the bounding box for the ellipse core.
lsst::afw::geom::ellipses::BaseCore::scale
void scale(double factor)
Scale the size of the ellipse core by the given factor.
Definition: BaseCore.cc:104
lsst::afw::geom::ellipses::BaseCore::_assignQuadrupoleToAxes
static void _assignQuadrupoleToAxes(double ixx, double iyy, double ixy, double &a, double &b, double &theta)
Return the size of the bounding box for the ellipse core.
Definition: BaseCore.cc:184
lsst::afw::geom::ellipses::BaseCore::Convolution
A temporary-only expression object for ellipse core convolution.
Definition: Convolution.h:46