casacore
Loading...
Searching...
No Matches
LCEllipsoid.h
Go to the documentation of this file.
1// # LCEllipsoid.h: Define an N-dimensional ellipsoidal region of interest
2// # Copyright (C) 1997,1998
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef LATTICES_LCELLIPSOID_H
27#define LATTICES_LCELLIPSOID_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/LRegions/LCRegionFixed.h>
32#include <casacore/casa/Arrays/Vector.h>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// <summary>
37// Define an N-dimensional ellipsoidal region of interest.
38// </summary>
39
40// <use visibility=export>
41
42// <reviewed reviewer="" date="" tests="">
43// </reviewed>
44
45// <prerequisite>
46// <li> <linkto class=LCRegion>LCRegion</linkto>
47// </prerequisite>
48
49// <synopsis>
50// The LCEllipsoid class is a specialization of class
51// <linkto class=LCRegion>LCRegion</linkto>.
52// It makes it possible to define an N-dimensional ellipsoidal region
53// of interest, which includes the border. A separate constructor exists
54// to define the special case of an N-dimensional sphere.
55// <br>
56// The center and the radii of the ellipsoid do not need to be pixel aligned.
57// The center of the ellipsoid may be outside the lattice.
58// The current implementation only supports ellipsoids with axes parallel
59// to the lattice axes except in the case of a 2-D ellipse for which a
60// constructor is provided for specifying the angle between the x-axis
61// and major axis of the ellipse.
62// <p>
63// It can only be used for a lattice of any dimensionality as long as the
64// dimensionality of the (hyper-)ellipsoid matches the dimensionality of
65// the lattice.
66// </synopsis>
67
68// <example>
69// <srcblock>
70// </srcblock>
71// </example>
72
73// <todo asof="1997/11/11">
74// <li> Arguments to have ellipsoid axes not parallel to lattice axes for
75// dimensions greater than 2. This is a nontrivial problem because of the
76// complexity of the rotation matrices involved.
77// </todo>
78
79class LCEllipsoid : public LCRegionFixed {
80 public:
82
83 // Construct an N-dimensional sphere with the given center and
84 // radius (in pixels). The center is pixel-aligned.
86
87 // Construct an N-dimensional sphere with the given center and
88 // radius (in pixels). The center does not need to be pixel-aligned.
89 // <group>
92 // </group>
93
94 // Construct an N-dimensional ellipsoid with the given center and
95 // radii (in pixels). The center does not need to be pixel-aligned.
96 // (the radii are half the length of the axes of the ellipsoid).
97 // <group>
99 const IPosition& latticeShape);
101 const IPosition& latticeShape);
102 // </group>
103
104 // Construct a two dimensional ellipse with theta being the angle from
105 // the x-axis to the major axis of the ellipse in radians.
106 LCEllipsoid(const Float xcenter, const Float ycenter, const Float majorAxis,
107 const Float minorAxis, const Float theta, const IPosition& latticeShape);
108
109 // Copy constructor (reference semantics).
111
112 virtual ~LCEllipsoid();
113
114 // Assignment (copy semantics).
116
117 // Make a copy of the derived object.
118 LCRegion* cloneRegion() const override;
119
120 // Get the center.
121 const Vector<Float>& center() const;
122
123 // Get the radii.
124 const Vector<Float>& radii() const;
125
126 // Get the angle of the major axis of the ellipse relative to the x-axis
127 // 2-D only, throws exception if ellipse is not 2-D.
128 const Float& theta() const;
129
130 // Get the class name (to store in the record).
132
133 // Get the region type. Returns className()
134 String type() const override;
135
136 // Convert the (derived) object to a record.
137 TableRecord toRecord(const String& tableName) const override;
138
139 // Convert correct object from a record.
140 static LCEllipsoid* fromRecord(const TableRecord&, const String& tableName);
141
142 protected:
143 // Construct another LCBox (for e.g. another lattice) by moving
144 // this one. It recalculates the bounding box.
145 // A positive translation value indicates "to right".
146 LCRegion* doTranslate(const Vector<Float>& translateVector,
147 const IPosition& newLatticeShape) const override;
148
149 private:
150 // Comparison
151 Bool equals(const LCRegion& other) const override;
152
153 // Fill the itsCenter vector from an IPosition.
155
156 // Make the bounding box from center, radii, and shape.
158
159 // Define the mask to indicate which elements are inside the ellipsoid.
161
162 // for 2-D ellipse with non-zero theta. Works for both cases center
163 // inside or outside the lattice.
165
166 // set the mask in the case the center lies outside the lattice
168
171 // small offset to guard against roundoff error
173 // for 2-D case only
175 // is center inside the lattice?
177};
178
179inline const Vector<Float>& LCEllipsoid::center() const { return itsCenter; }
180inline const Vector<Float>& LCEllipsoid::radii() const { return itsRadii; }
181
182} // namespace casacore
183
184#endif
Vector< Float > itsCenter
void _doOutside()
set the mask in the case the center lies outside the lattice
LCEllipsoid(const Vector< Float > &center, const Vector< Float > &radii, const IPosition &latticeShape)
Construct an N-dimensional ellipsoid with the given center and radii (in pixels).
static LCEllipsoid * fromRecord(const TableRecord &, const String &tableName)
Convert correct object from a record.
const Vector< Float > & center() const
Get the center.
LCRegion * cloneRegion() const override
Make a copy of the derived object.
void defineMask()
Define the mask to indicate which elements are inside the ellipsoid.
void _defineMask2D()
for 2-D ellipse with non-zero theta.
const Float & theta() const
Get the angle of the major axis of the ellipse relative to the x-axis 2-D only, throws exception if e...
LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const override
Construct another LCBox (for e.g.
const Vector< Float > & radii() const
Get the radii.
String type() const override
Get the region type.
LCEllipsoid(const Float xcenter, const Float ycenter, const Float majorAxis, const Float minorAxis, const Float theta, const IPosition &latticeShape)
Construct a two dimensional ellipse with theta being the angle from the x-axis to the major axis of t...
Bool equals(const LCRegion &other) const override
Comparison.
TableRecord toRecord(const String &tableName) const override
Convert the (derived) object to a record.
LCEllipsoid(const LCEllipsoid &other)
Copy constructor (reference semantics).
Slicer makeBox(const Vector< Float > &radii, const IPosition &latticeShape)
Make the bounding box from center, radii, and shape.
Vector< Float > itsRadii
LCEllipsoid & operator=(const LCEllipsoid &other)
Assignment (copy semantics).
LCEllipsoid(const IPosition &center, Float radius, const IPosition &latticeShape)
Construct an N-dimensional sphere with the given center and radius (in pixels).
LCEllipsoid(const Vector< Double > &center, const Vector< Double > &radii, const IPosition &latticeShape)
Bool _centerIsInside
is center inside the lattice?
void fillCenter(const IPosition &center)
Fill the itsCenter vector from an IPosition.
Vector< Float > _epsilon
small offset to guard against roundoff error
LCEllipsoid(const Vector< Float > &center, Float radius, const IPosition &latticeShape)
Construct an N-dimensional sphere with the given center and radius (in pixels).
Float _theta
for 2-D case only
LCEllipsoid(const Vector< Double > &center, Double radius, const IPosition &latticeShape)
static String className()
Get the class name (to store in the record).
const IPosition & latticeShape() const
Give the full lattice shape.
Definition LCRegion.h:211
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
float Float
Definition aipstype.h:52
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53