LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 
37 #include "lsst/afw/geom/Box.h"
39 
40 namespace lsst { namespace afw { namespace geom { namespace ellipses {
41 
50 class Ellipse {
51 public:
52 #ifndef SWIG
53  class Transformer;
54  class GridTransform;
55  class Convolution;
56 #endif
57 
58  typedef Eigen::Matrix<double,5,1> ParameterVector;
59 
60  typedef std::shared_ptr<Ellipse> Ptr;
61  typedef std::shared_ptr<Ellipse const> ConstPtr;
62 
63  enum ParameterEnum { X=3, Y=4 };
64 
66  Point2D const & getCenter() const { return _center; }
67 
69  Point2D & getCenter() { return _center; }
70 
72  void setCenter(Point2D const & center) { _center = center; }
73 
75  BaseCore const & getCore() const { return *_core; }
76 
78  BaseCore & getCore() { return *_core; }
79 
81  BaseCore::ConstPtr getCorePtr() const { return _core; }
82 
85 
87  void setCore(BaseCore const & core) { *_core = core; }
88 
90  void normalize() { _core->normalize(); }
91 
93  void grow(double buffer) { _core->grow(buffer); }
94 
96  void scale(double factor) { _core->scale(factor); }
97 
99  void shift(Extent2D const & offset) { _center += offset; }
100 
102  ParameterVector const getParameterVector() const;
103 
105  void setParameterVector(ParameterVector const & vector);
106 
107  void readParameters(double const * iter);
108 
109  void writeParameters(double * iter) const;
110 
119  Transformer transform(AffineTransform const & transform);
120  Transformer const transform(AffineTransform const & transform) const;
122 
127  Convolution convolve(Ellipse const & other);
128  Convolution const convolve(Ellipse const & other) const;
130 
137  GridTransform const getGridTransform() const;
138 
140  Box2D computeBBox() const;
141 
147  Ellipse & operator=(Ellipse const & other);
148 
154  bool operator==(Ellipse const & other) const {
155  return getCenter() == other.getCenter() && getCore() == other.getCore();
156  }
157 
163  bool operator!=(Ellipse const & other) const { return !operator==(other); }
164 
165  virtual ~Ellipse() {}
166 
167  explicit Ellipse(BaseCore const & core, Point2D const & center = Point2D()) :
168  _core(core.clone()), _center(center) {}
169 
170  explicit Ellipse(BaseCore::ConstPtr const & core, Point2D const & center = Point2D()) :
171  _core(core->clone()), _center(center) {}
172 
173 #ifndef SWIG
174  Ellipse(Transformer const & other);
175  Ellipse(Convolution const & other);
176 #endif
177 
178  Ellipse(Ellipse const & other) :
179  _core(other.getCore().clone()), _center(other.getCenter()) {}
180 
181 private:
184 };
185 
186 }}}} // namespace lsst::afw::geom::ellipses
187 
188 #endif // !LSST_AFW_GEOM_ELLIPSES_Ellipse_h_INCLUDED
int iter
bool operator!=(Ellipse const &other) const
Compare two ellipses for inequality.
Definition: Ellipse.h:163
std::shared_ptr< Ellipse const > ConstPtr
Definition: Ellipse.h:61
std::shared_ptr< Ellipse > Ptr
Definition: Ellipse.h:60
BaseCore::Ptr getCorePtr()
Return the ellipse core.
Definition: Ellipse.h:84
void grow(double buffer)
Increase the major and minor radii of the ellipse by the given buffer.
Definition: Ellipse.h:93
BaseCore const & getCore() const
Return the ellipse core.
Definition: Ellipse.h:75
Ellipse(BaseCore::ConstPtr const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:170
std::shared_ptr< BaseCore > Ptr
Definition: BaseCore.h:59
Box2D computeBBox() const
Return the bounding box of the ellipse.
bool operator==(Ellipse const &other) const
Compare two ellipses for equality.
Definition: Ellipse.h:154
Point2D const & getCenter() const
Return the center point.
Definition: Ellipse.h:66
GridTransform const getGridTransform() const
Return the transform that maps the ellipse to the unit circle.
void scale(double factor)
Scale the size of the ellipse by the given factor.
Definition: Ellipse.h:96
Ellipse(Ellipse const &other)
Definition: Ellipse.h:178
void setCore(BaseCore const &core)
Set the ellipse core; the type of the core is not changed.
Definition: Ellipse.h:87
Forward declarations, typedefs, and definitions for BaseCore.
An affine coordinate transformation consisting of a linear transformation and an offset.
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
Ellipse & operator=(Ellipse const &other)
Set the parameters of this ellipse from another.
ParameterVector const getParameterVector() const
Return the ellipse parameters as a vector.
void readParameters(double const *iter)
BaseCore::ConstPtr getCorePtr() const
Return the ellipse core.
Definition: Ellipse.h:81
Transformer transform(AffineTransform const &transform)
Definition: Transformer.h:125
void shift(Extent2D const &offset)
Move the ellipse center by the given offset.
Definition: Ellipse.h:99
std::shared_ptr< BaseCore const > ConstPtr
Definition: BaseCore.h:63
BaseCore & getCore()
Return the ellipse core.
Definition: Ellipse.h:78
Point2D & getCenter()
Return the center point.
Definition: Ellipse.h:69
A base class for parametrizations of the &quot;core&quot; of an ellipse - the ellipticity and size...
Definition: BaseCore.h:53
Point< double, 2 > Point2D
Definition: Point.h:288
A temporary-only expression object for ellipse convolution.
Definition: Convolution.h:73
A temporary-only expression object for ellipse transformations.
Definition: Transformer.h:86
Eigen::Matrix< double, 5, 1 > ParameterVector
Proxy return type for Ellipse::convolve().
Definition: Ellipse.h:55
void setCenter(Point2D const &center)
Set the center point.
Definition: Ellipse.h:72
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:271
Convolution convolve(Ellipse const &other)
Definition: Convolution.h:105
void normalize()
Put the parameters in a standard form.
Definition: Ellipse.h:90
void setParameterVector(ParameterVector const &vector)
Set the ellipse parameters from a vector.
Ellipse(BaseCore const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:167
void writeParameters(double *iter) const