LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 boost::shared_ptr<Ellipse> Ptr;
61  typedef boost::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
boost::shared_ptr< BaseCore > Ptr
Definition: BaseCore.h:60
BaseCore::ConstPtr getCorePtr() const
Return the ellipse core.
Definition: Ellipse.h:81
void scale(double factor)
Scale the size of the ellipse by the given factor.
Definition: Ellipse.h:96
BaseCore & getCore()
Return the ellipse core.
Definition: Ellipse.h:78
Ellipse & operator=(Ellipse const &other)
Set the parameters of this ellipse from another.
bool operator==(Ellipse const &other) const
Compare two ellipses for equality.
Definition: Ellipse.h:154
BaseCore::Ptr getCorePtr()
Return the ellipse core.
Definition: Ellipse.h:84
Point< double, 2 > Point2D
Definition: Point.h:286
Point2D const & getCenter() const
Return the center point.
Definition: Ellipse.h:66
Eigen::Matrix< double, 5, 1 > ParameterVector
Proxy return type for Ellipse::convolve().
Definition: Ellipse.h:55
boost::shared_ptr< BaseCore const > ConstPtr
Definition: BaseCore.h:64
Box2D computeBBox() const
Return the bounding box of the ellipse.
Ellipse(BaseCore const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:167
void normalize()
Put the parameters in a standard form.
Definition: Ellipse.h:90
void readParameters(double const *iter)
Transformer transform(AffineTransform const &transform)
Definition: Transformer.h:125
ParameterVector const getParameterVector() const
Return the ellipse parameters as a vector.
Forward declarations, typedefs, and definitions for BaseCore.
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:87
An ellipse defined by an arbitrary BaseCore and a center point.
Definition: Ellipse.h:50
void setCenter(Point2D const &center)
Set the center point.
Definition: Ellipse.h:72
BaseCore const & getCore() const
Return the ellipse core.
Definition: Ellipse.h:75
void grow(double buffer)
Increase the major and minor radii of the ellipse by the given buffer.
Definition: Ellipse.h:93
Ellipse(Ellipse const &other)
Definition: Ellipse.h:178
A base class for parametrizations of the &quot;core&quot; of an ellipse - the ellipticity and size...
Definition: BaseCore.h:54
void shift(Extent2D const &offset)
Move the ellipse center by the given offset.
Definition: Ellipse.h:99
void setParameterVector(ParameterVector const &vector)
Set the ellipse parameters from a vector.
GridTransform const getGridTransform() const
Return the transform that maps the ellipse to the unit circle.
A temporary-only expression object for ellipse convolution.
Definition: Convolution.h:73
A temporary-only expression object for ellipse transformations.
Definition: Transformer.h:86
Point2D & getCenter()
Return the center point.
Definition: Ellipse.h:69
Ellipse(BaseCore::ConstPtr const &core, Point2D const &center=Point2D())
Definition: Ellipse.h:170
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
boost::shared_ptr< Ellipse > Ptr
Definition: Ellipse.h:60
boost::shared_ptr< Ellipse const > ConstPtr
Definition: Ellipse.h:61
void writeParameters(double *iter) const
Convolution convolve(Ellipse const &other)
Definition: Convolution.h:105