LSSTApplications  11.0-24-g0a022a1,15.0+13,15.0+9,15.0-1-g19261fa+5,15.0-1-g1eca518+15,15.0-1-g60afb23+12,15.0-1-g615e0bb+4,15.0-1-g6668b0b+5,15.0-1-g788a293+12,15.0-1-ga91101e+12,15.0-1-gae1598d+8,15.0-1-gc45031d+15,15.0-1-gd076f1f+12,15.0-1-gdf18595+2,15.0-1-gf4f1c34+8,15.0-2-g100d730+5,15.0-2-g18f3f21+5,15.0-2-g35685a8+6,15.0-2-gf38729e+5,15.0-21-g91b8abf62,15.0-3-g150fc43+14,15.0-3-g6f085af+5,15.0-3-g707930d,15.0-3-g9103c06+8,15.0-3-ga03b4ca+16,15.0-3-gaec6799+5,15.0-3-gb7a597c+12,15.0-3-ge6a6747+5,15.0-4-g45f767a+8,15.0-4-g654b129+10,15.0-4-gf5d1e39,15.0-4-gff20472+15,15.0-5-ga70c291+5,15.0-6-g9a9df217+5,15.0-7-gab4c137+6,15.0-7-gab79a70c+4
LSSTDataManagementBasePackage
Ellipse.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_Ellipse_h_INCLUDED
26 #define LSST_AFW_GEOM_ELLIPSES_Ellipse_h_INCLUDED
27 
28 /*
29  * Forward declarations, typedefs, and definitions for Ellipse.
30  *
31  * Note: do not include directly; use the main ellipse header file.
32  */
33 
35 #include "lsst/afw/geom/Box.h"
37 
38 namespace lsst {
39 namespace afw {
40 namespace geom {
41 namespace ellipses {
42 
51 class Ellipse {
52 public:
53  class Transformer;
54  class GridTransform;
55  class Convolution;
56 
57  typedef Eigen::Matrix<double, 5, 1> ParameterVector;
58 
59  enum ParameterEnum { X = 3, Y = 4 };
60 
62  Point2D const& getCenter() const { return _center; }
63 
65  Point2D& getCenter() { return _center; }
66 
68  void setCenter(Point2D const& center) { _center = center; }
69 
71  BaseCore const& getCore() const { return *_core; }
72 
74  BaseCore& getCore() { return *_core; }
75 
77  std::shared_ptr<BaseCore const> getCorePtr() const { return _core; }
78 
81 
83  void setCore(BaseCore const& core) { *_core = core; }
84 
86  void normalize() { _core->normalize(); }
87 
89  void grow(double buffer) { _core->grow(buffer); }
90 
92  void scale(double factor) { _core->scale(factor); }
93 
95  void shift(Extent2D const& offset) { _center += offset; }
96 
98  ParameterVector const getParameterVector() const;
99 
101  void setParameterVector(ParameterVector const& vector);
102 
103  void readParameters(double const* iter);
104 
105  void writeParameters(double* iter) const;
106 
116  Transformer const transform(AffineTransform const& transform) const;
118 
123  Convolution convolve(Ellipse const& other);
124  Convolution const convolve(Ellipse const& other) const;
126 
133  GridTransform const getGridTransform() const;
134 
136  Box2D computeBBox() const;
137 
143  Ellipse& operator=(Ellipse const& other);
144  Ellipse& operator=(Ellipse&& other);
145 
151  bool operator==(Ellipse const& other) const {
152  return getCenter() == other.getCenter() && getCore() == other.getCore();
153  }
154 
160  bool operator!=(Ellipse const& other) const { return !operator==(other); }
161 
162  virtual ~Ellipse() = default;
163 
164  explicit Ellipse(BaseCore const& core, Point2D const& center = Point2D())
165  : _core(core.clone()), _center(center) {}
166 
167  explicit Ellipse(std::shared_ptr<BaseCore const> const& core, Point2D const& center = Point2D())
168  : _core(core->clone()), _center(center) {}
169 
170  Ellipse(Transformer const& other);
171  Ellipse(Convolution const& other);
172 
173  Ellipse(Ellipse const& other) : _core(other.getCore().clone()), _center(other.getCenter()) {}
174  // Delegate to copy-constructor for backwards compatibility
175  Ellipse(Ellipse&& other) : Ellipse(other) {}
176 
177 private:
179  Point2D _center;
180 };
181 }
182 }
183 }
184 } // namespace lsst::afw::geom::ellipses
185 
186 #endif // !LSST_AFW_GEOM_ELLIPSES_Ellipse_h_INCLUDED
bool operator!=(Ellipse const &other) const
Compare two ellipses for inequality.
Definition: Ellipse.h:160
void scale(double factor)
Scale the size of the ellipse by the given factor.
Definition: Ellipse.h:92
BaseCore & getCore()
Return the ellipse core.
Definition: Ellipse.h:74
BaseCore const & getCore() const
Return the ellipse core.
Definition: Ellipse.h:71
Eigen::Matrix< double, 5, 1 > ParameterVector
Proxy return type for Ellipse::convolve().
Definition: Ellipse.h:55
Ellipse & operator=(Ellipse const &other)
Set the parameters of this ellipse from another.
Definition: Ellipse.cc:60
std::shared_ptr< BaseCore > getCorePtr()
Return the ellipse core.
Definition: Ellipse.h:80
Ellipse(BaseCore const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:164
void normalize()
Put the parameters in a standard form.
Definition: Ellipse.h:86
void readParameters(double const *iter)
Definition: Ellipse.cc:43
A base class for image defects.
Definition: cameraGeom.dox:3
Transformer transform(AffineTransform const &transform)
Definition: Transformer.h:122
Point< double, 2 > Point2D
Definition: Point.h:304
An affine coordinate transformation consisting of a linear transformation and an offset.
void setCore(BaseCore const &core)
Set the ellipse core; the type of the core is not changed.
Definition: Ellipse.h:83
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:51
void setCenter(Point2D const &center)
Set the center point.
Definition: Ellipse.h:68
void grow(double buffer)
Increase the major and minor radii of the ellipse by the given buffer.
Definition: Ellipse.h:89
Ellipse(Ellipse const &other)
Definition: Ellipse.h:173
GridTransform const getGridTransform() const
Return the transform that maps the ellipse to the unit circle.
Ellipse(std::shared_ptr< BaseCore const > const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:167
Point2D const & getCenter() const
Return the center point.
Definition: Ellipse.h:62
Box2D computeBBox() const
Return the bounding box of the ellipse.
Definition: Ellipse.cc:55
A base class for parametrizations of the "core" of an ellipse - the ellipticity and size...
Definition: BaseCore.h:55
void shift(Extent2D const &offset)
Move the ellipse center by the given offset.
Definition: Ellipse.h:95
void setParameterVector(ParameterVector const &vector)
Set the ellipse parameters from a vector.
Definition: Ellipse.cc:38
A temporary-only expression object for ellipse transformations.
Definition: Transformer.h:85
std::shared_ptr< BaseCore const > getCorePtr() const
Return the ellipse core.
Definition: Ellipse.h:77
ItemVariant const * other
Definition: Schema.cc:55
Point2D & getCenter()
Return the center point.
Definition: Ellipse.h:65
A temporary-only expression object representing an AffineTransform that maps the Ellipse to a unit ci...
Definition: GridTransform.h:80
A floating-point coordinate rectangle geometry.
Definition: Box.h:266
bool operator==(Ellipse const &other) const
Compare two ellipses for equality.
Definition: Ellipse.h:151
void writeParameters(double *iter) const
Definition: Ellipse.cc:49
ParameterVector const getParameterVector() const
Return the ellipse parameters as a vector.
Definition: Ellipse.cc:31
Convolution convolve(Ellipse const &other)
Definition: Convolution.h:101