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
34
35namespace casacore { //# NAMESPACE CASACORE - BEGIN
36
37// <summary>
38// Define an N-dimensional ellipsoidal region of interest.
39// </summary>
40
41// <use visibility=export>
42
43// <reviewed reviewer="" date="" tests="">
44// </reviewed>
45
46// <prerequisite>
47// <li> <linkto class=LCRegion>LCRegion</linkto>
48// </prerequisite>
49
50// <synopsis>
51// The LCEllipsoid class is a specialization of class
52// <linkto class=LCRegion>LCRegion</linkto>.
53// It makes it possible to define an N-dimensional ellipsoidal region
54// of interest, which includes the border. A separate constructor exists
55// to define the special case of an N-dimensional sphere.
56// <br>
57// The center and the radii of the ellipsoid do not need to be pixel aligned.
58// The center of the ellipsoid may be outside the lattice.
59// The current implementation only supports ellipsoids with axes parallel
60// to the lattice axes except in the case of a 2-D ellipse for which a
61// constructor is provided for specifying the angle between the x-axis
62// and major axis of the ellipse.
63// <p>
64// It can only be used for a lattice of any dimensionality as long as the
65// dimensionality of the (hyper-)ellipsoid matches the dimensionality of
66// the lattice.
67// </synopsis>
68
69// <example>
70// <srcblock>
71// </srcblock>
72// </example>
73
74// <todo asof="1997/11/11">
75// <li> Arguments to have ellipsoid axes not parallel to lattice axes for
76// dimensions greater than 2. This is a nontrivial problem because of the
77// complexity of the rotation matrices involved.
78// </todo>
79
80
82{
83public:
85
86 // Construct an N-dimensional sphere with the given center and
87 // radius (in pixels). The center is pixel-aligned.
89 const IPosition& latticeShape);
90
91 // Construct an N-dimensional sphere with the given center and
92 // radius (in pixels). The center does not need to be pixel-aligned.
93 // <group>
95 const IPosition& latticeShape);
97 const IPosition& latticeShape);
98 // </group>
99
100 // Construct an N-dimensional ellipsoid with the given center and
101 // radii (in pixels). The center does not need to be pixel-aligned.
102 // (the radii are half the length of the axes of the ellipsoid).
103 // <group>
105 const IPosition& latticeShape);
107 const IPosition& latticeShape);
108 // </group>
109
110 // Construct a two dimensional ellipse with theta being the angle from
111 // the x-axis to the major axis of the ellipse in radians.
113 const Float xcenter, const Float ycenter,
114 const Float majorAxis, const Float minorAxis,
115 const Float theta, const IPosition& latticeShape
116 );
117
118 // Copy constructor (reference semantics).
119 LCEllipsoid (const LCEllipsoid& other);
120
121 virtual ~LCEllipsoid();
122
123 // Assignment (copy semantics).
125
126 // Comparison
127 virtual Bool operator== (const LCRegion& other) const;
128
129 // Make a copy of the derived object.
130 virtual LCRegion* cloneRegion() const;
131
132 // Get the center.
133 const Vector<Float>& center() const;
134
135 // Get the radii.
136 const Vector<Float>& radii() const;
137
138 // Get the angle of the major axis of the ellipse relative to the x-axis
139 // 2-D only, throws exception if ellipse is not 2-D.
140 const Float& theta() const;
141
142 // Get the class name (to store in the record).
144
145 // Get the region type. Returns className()
146 virtual String type() const;
147
148 // Convert the (derived) object to a record.
149 virtual TableRecord toRecord (const String& tableName) const;
150
151 // Convert correct object from a record.
153 const String& tableName);
154
155protected:
156 // Construct another LCBox (for e.g. another lattice) by moving
157 // this one. It recalculates the bounding box.
158 // A positive translation value indicates "to right".
159 virtual LCRegion* doTranslate (const Vector<Float>& translateVector,
160 const IPosition& newLatticeShape) const;
161
162private:
163 // Fill the itsCenter vector from an IPosition.
165
166 // Make the bounding box from center, radii, and shape.
168 const IPosition& latticeShape);
169
170 // Define the mask to indicate which elements are inside the ellipsoid.
172
173 //for 2-D ellipse with non-zero theta. Works for both cases center
174 // inside or outside the lattice.
176
177 // set the mask in the case the center lies outside the lattice
179
182 // small offset to guard against roundoff error
184 // for 2-D case only
186 // is center inside the lattice?
188};
189
190
192{
193 return itsCenter;
194}
196{
197 return itsRadii;
198}
199
200
201
202} //# NAMESPACE CASACORE - END
203
204#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.
virtual TableRecord toRecord(const String &tableName) const
Convert the (derived) object to a record.
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...
const Vector< Float > & radii() const
Get the radii.
virtual String type() const
Get the region type.
virtual LCRegion * doTranslate(const Vector< Float > &translateVector, const IPosition &newLatticeShape) const
Construct another LCBox (for e.g.
virtual Bool operator==(const LCRegion &other) const
Comparison.
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...
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).
virtual LCRegion * cloneRegion() const
Make a copy of the derived object.
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:229
String: the storage and methods of handling collections of characters.
Definition String.h:223
this file contains all the compiler specific defines
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