casacore
Loading...
Searching...
No Matches
MVPosition.h
Go to the documentation of this file.
1// # MVPosition.h: A 3D vector in space
2// # Copyright (C) 1996,1997,1998,1999,2000,2001
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 CASA_MVPOSITION_H
27#define CASA_MVPOSITION_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/casa/Arrays/Vector.h>
32#include <casacore/casa/Quanta/Unit.h>
33#include <casacore/casa/Quanta/Quantum.h>
34#include <casacore/casa/Quanta/MeasValue.h>
35#include <casacore/casa/iosfwd.h>
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward Declarations
40class RotMatrix;
41
42// # Constants (SUN compiler does not accept non-simple default arguments)
43
44// <summary> A 3D vector in space </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
49// </reviewed>
50
51// <prerequisite>
52// <li> <linkto class=MeasValue>MeasValue</linkto>
53// <li> <linkto class=Vector>Vector</linkto>
54// <li> <linkto class=Quantum>Quantum</linkto>
55// </prerequisite>
56//
57// <etymology>
58// From Measure, Value and Position
59// </etymology>
60//
61// <synopsis>
62// A MVPosition is a 3-vector of positions in a rectangular frame with
63// internal units of m.<br>
64// It can be constructed with:
65// <ul>
66// <li> MVPosition() creates point at origin (0,0,0)
67// <li> MVPosition(MVPosition) creates a copy
68// <li> MVPosition(Double, Double, Double) creates (x,y,z) with
69// specified values
70// <li> MVPosition(Quantity length,Double, Double) creates a MVPosition assuming
71// that the two values are (in radians) angle along 'equator'
72// and towards 'pole'. A length of zero will be made 1um.
73// <li> MVPosition(Quantity length, Quantity, Quantity) creates a MVPosition
74// assuming angles as in previous, or positions
75// <li> <src>MVPosition(Quantity, Quantum<Vector<Double> >)</src> creates a
76// MVPosition from angle vector, using first two angles, and
77// assuming second as zero if not present, and pole if length 0.
78// <li> <src>MVPosition(Quantum<Vector<Double> ></src> creates from
79// angles or positions, depending on the units in the
80// quantum vector. In the angle case,
81// the data derived can be scaled with the readjust() function. If
82// the unit of the quantum vector is length, position is
83// assumed.
84// <li> <src>MVPosition(Vector<Double></src> creates from angles (less than
85// or equal to two elements) or x,y,z (3 elements).
86// <li> <src>MVPosition(Vector<Quantity></src> creates from length+angles,
87// angles, or x,y,z, depending on units.
88// </ul>
89// A void adjust(Double) function normalises the vector to a length of 1;
90// a get() returns as a
91// Double 3-vector the length and angles of the position vector;
92// a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated
93// element, and getValue returns the vector.<br>
94// Positions can be added and subtracted.<br>
95// The multiplication of two positions produces the in-product.<br>
96// </synopsis>
97//
98// <example>
99// See <linkto class=MPosition>Mposition</linkto> class.
100// </example>
101//
102// <motivation>
103// To do coordinate transformations
104// </motivation>
105//
106// <todo asof="1996/02/04">
107// <li> See if not better to have a direction + length
108// </todo>
109
110class MVPosition : public MeasValue {
111 public:
112 // # Constants
113 // Internal limts codes for negative height
114 // <group>
115 static const Double loLimit;
116 static const Double hiLimit;
117 // </group>
118 // # Friends
119
120 // # Constructors
121 // Default constructor generates a (0,0,0) position
123 // Copy constructor
124 MVPosition(const MVPosition &other);
125 // Creates a specified vector
127 // Creates a vector with specified length towards pole
128 // <group>
129 explicit MVPosition(Double in0);
131 // </group>
132 // Creates the position from specified (azimuth,elevation) angles and length
133 MVPosition(const Quantity &l, Double angle0, Double angle1);
134 // Creates the position from specified angles and length. or positions
135 // <thrown>
136 // <li> AipsError if quantities not in angle format
137 // </thrown>
138 // <group>
139 MVPosition(const Quantity &l, const Quantity &angle0, const Quantity &angle1);
140 // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
142 MVPosition(const Quantity &l, const Quantum<Vector<Double>> &angle);
143 // </group>
144 // Create from specified length and/or angles and/or position
145 // <group>
146 explicit MVPosition(const Vector<Double> &other);
148 // </group>
149 // Copy assignment
151
152 // Destructor
153 virtual ~MVPosition();
154
155 // # Operators
156 // Multiplication defined as in-product
157 // <group>
158 Double operator*(const MVPosition &other) const;
159 // </group>
160
161 // Equality comparisons
162 // <group>
163 Bool operator==(const MVPosition &other) const;
164 Bool operator!=(const MVPosition &other) const;
165 Bool near(const MVPosition &other, Double tol = 1e-13) const;
166 Bool near(const MVPosition &other, Quantity tol) const;
167 Bool nearAbs(const MVPosition &other, Double tol = 1e-13) const;
168 // </group>
169
170 // Addition and subtraction
171 // <group>
174 MVPosition operator+(const MVPosition &right) const;
176 MVPosition operator-(const MVPosition &right) const;
177 // </group>
178
179 // Multiplication with rotation matrix (see also global functions)
180 // <group>
182 // </group>
183
184 // Multiplication with constant
185 // <group>
187 // </group>
188
189 // Obtain an element
190 // <group>
192 const Double &operator()(uInt which) const;
193 // </group>
194
195 // # General Member Functions
196
197 // Tell me your type
198 // <group>
199 static void assure(const MeasValue &in);
200 // </group>
201
202 // Normalise direction aspects by adjusting the length to 1
203 // <group>
204 // For position no adjustment; for direction adjustment
205 virtual void adjust();
206 // Adjustment with returned factor
207 virtual void adjust(Double &res);
208 // Re-adjust using factor given
209 virtual void readjust(Double res);
210 // </group>
211 // Get radius of position
212 virtual Double radius();
213 // Generate a 3-vector of coordinates (length(m), angles(rad))
215 // Generate a 3-vector of x,y,z in m
216 const Vector<Double> &getValue() const;
217 // Generate angle 2-vector (in rad)
219 // and with specified units
221 // Get the longitudinal angle (in radians)
223 // and with specified units
224 Quantity getLong(const Unit &unit) const;
225 // Get the latitude angle (rad)
226 Double getLat() const;
227 // and with specified units
228 Quantity getLat(const Unit &unit) const;
229 // Generate the length
231 // and generate it with the specified units
232 Quantity getLength(const Unit &unit) const;
233 // Get the position angle between the directions. I.e. the angle between
234 // the direction from one to the pole, and from one to the other.
235 // <group>
236 Double positionAngle(const MVPosition &other) const;
237 Quantity positionAngle(const MVPosition &other, const Unit &unit) const;
238 // </group>
239 // Get the angular separation between two directions.
240 // <group>
241 Double separation(const MVPosition &other) const;
242 Quantity separation(const MVPosition &other, const Unit &unit) const;
243 // </group>
244 // Produce the cross product
245 MVPosition crossProduct(const MVPosition &other) const;
246
247 // Print data
248 virtual void print(ostream &os) const;
249 // Clone
250 virtual MeasValue *clone() const;
251
252 // Get the value in internal units
253 virtual Vector<Double> getVector() const;
254 // Set the value from internal units (set 0 for empty vector)
255 virtual void putVector(const Vector<Double> &in);
256 // Get the internal value as a <src>Vector<Quantity></src>. Usable in
257 // records. The getXRecordValue() gets additional information for records.
258 // Note that the Vectors could be empty.
259 // <group>
263 // </group>
264 // Set the internal value if correct values and dimensions
265 virtual Bool putValue(const Vector<Quantum<Double>> &in);
266
267 protected:
268 // # Member functions
269 // Get the latitude assuming length is given
271 // # Data
272 // Position vector (in m)
274};
275
276// # Global functions
277// Rotate a position vector with rotation matrix and other multiplications
278// <group>
279MVPosition operator*(const RotMatrix &left, const MVPosition &right);
280MVPosition operator*(const MVPosition &left, const RotMatrix &right);
283Double operator*(const Vector<Double> &left, const MVPosition &right);
284Double operator*(const MVPosition &left, const Vector<Double> &right);
285// </group>
286
287} // namespace casacore
288
289#endif
Double & operator()(uInt which)
Obtain an element.
Quantum< Vector< Double > > getAngle(const Unit &unit) const
and with specified units
MVPosition & operator*=(const RotMatrix &right)
Multiplication with rotation matrix (see also global functions).
Quantum< Vector< Double > > getAngle() const
Generate angle 2-vector (in rad).
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
MVPosition()
Default constructor generates a (0,0,0) position.
static void assure(const MeasValue &in)
Tell me your type.
const Double & operator()(uInt which) const
Double operator*(const MVPosition &other) const
Multiplication defined as in-product.
MVPosition operator-(const MVPosition &right) const
Double getLong() const
Get the longitudinal angle (in radians).
virtual ~MVPosition()
Destructor.
Quantity getLength(const Unit &unit) const
and generate it with the specified units
static const Double hiLimit
Definition MVPosition.h:116
virtual Double radius()
Get radius of position.
virtual void adjust()
Normalise direction aspects by adjusting the length to 1.
Vector< Double > xyz
Position vector (in m).
Definition MVPosition.h:273
MVPosition(const Quantity &l, const Quantity &angle0, const Quantity &angle1)
Creates the position from specified angles and length.
MVPosition(const Quantity &l, Double angle0, Double angle1)
Creates the position from specified (azimuth,elevation) angles and length.
virtual void print(ostream &os) const
Print data.
static const Double loLimit
Internal limts codes for negative height.
Definition MVPosition.h:115
MVPosition(Double in0)
Creates a vector with specified length towards pole.
virtual Vector< Quantum< Double > > getXRecordValue() const
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector<Quantity>.
MVPosition(const Quantum< Vector< Double > > &angle)
If not enough angles: pole assumed (if none), or elevation =0 (if 1).
Double positionAngle(const MVPosition &other) const
Get the position angle between the directions.
MVPosition & operator-=(const MVPosition &right)
Double getLat() const
Get the latitude angle (rad).
Bool operator==(const MVPosition &other) const
Equality comparisons.
virtual void readjust(Double res)
Re-adjust using factor given.
const Vector< Double > & getValue() const
Generate a 3-vector of x,y,z in m.
MVPosition(const Vector< Double > &other)
Create from specified length and/or angles and/or position.
Quantity getLength() const
Generate the length.
Bool nearAbs(const MVPosition &other, Double tol=1e-13) const
virtual void adjust(Double &res)
Adjustment with returned factor.
Quantity positionAngle(const MVPosition &other, const Unit &unit) const
MVPosition(const MVPosition &other)
Copy constructor.
MVPosition & operator=(const MVPosition &other)
Copy assignment.
Double separation(const MVPosition &other) const
Get the angular separation between two directions.
MVPosition & operator*=(Double right)
Multiplication with constant.
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector).
virtual Vector< Quantum< Double > > getTMRecordValue() const
Definition MVPosition.h:262
Bool near(const MVPosition &other, Double tol=1e-13) const
MVPosition(const Quantity &l, const Quantum< Vector< Double > > &angle)
MVPosition(const Quantity &l)
MVPosition crossProduct(const MVPosition &other) const
Produce the cross product.
MVPosition(const Vector< Quantity > &other)
MVPosition operator-() const
Addition and subtraction.
Bool near(const MVPosition &other, Quantity tol) const
Bool operator!=(const MVPosition &other) const
MVPosition(Double in0, Double in1, Double in2)
Creates a specified vector.
virtual Vector< Double > getVector() const
Get the value in internal units.
MVPosition & operator+=(const MVPosition &right)
Quantity getLat(const Unit &unit) const
and with specified units
Quantity separation(const MVPosition &other, const Unit &unit) const
MVPosition operator+(const MVPosition &right) const
virtual MeasValue * clone() const
Clone.
Vector< Double > get() const
Generate a 3-vector of coordinates (length(m), angles(rad)).
Double getLat(Double ln) const
Get the latitude assuming length is given.
Quantity getLong(const Unit &unit) const
and with specified units
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
T & operator*()
Provide access to the field's value.
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
Quantum< Double > Quantity
Definition Quantum.h:40
double Double
Definition aipstype.h:53