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