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