casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVuvw.h
Go to the documentation of this file.
1 //# MVuvw.h: A 3D vector on Earth
2 //# Copyright (C) 1998,2000
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_MVUVW_H
29 #define CASA_MVUVW_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class MVDirection;
39 class MVBaseline;
40 
41 // <summary> A 3D vector on Earth </summary>
42 
43 // <use visibility=export>
44 
45 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMuvw" demos="">
46 // </reviewed>
47 
48 // <prerequisite>
49 // <li> <linkto class=MeasValue>MeasValue</linkto>
50 // </prerequisite>
51 //
52 // <etymology>
53 // From Measure, Value and uvw
54 // </etymology>
55 //
56 // <synopsis>
57 // A MVuvw is a 3-vector of uvws in a rectangular frame with
58 // internal units of m.<br>
59 // It can be constructed with:
60 // <ul>
61 // <li> MVuvw() creates point at origin (0,0,0)
62 // <li> MVuvw(MVuvw) creates a copy
63 // <li> MVuvw(MVPosition) creates (x,y,z) from the given position
64 // <li> MVuvw(Double, Double, Double) creates (x,y,z) with
65 // specified values (assuming meters)
66 // <li> MVuvw(Quantity length,Double, Double) creates a MVuvw assuming
67 // that the two values are (in radians) angle along 'equator'
68 // and towards 'pole'.
69 // <li> MVuvw(Quantity length, Quantity, Quantity) creates a MVuvw
70 // assuming angles as in previous, or uvws
71 // <li> <src>MVuvw(Quantity, Quantum<Vector<Double> >)</src> creates a
72 // MVuvw from angle vector, using first two angles, and
73 // assuming second as zero if not present.
74 // <li> <src>MVuvw(Quantum<Vector<Double> ></src> creates from
75 // angles or uvws, depending on the units in the
76 // quantum vector. In the angle case,
77 // the data derived can be scaled with the readjust() function. If
78 // the unit of the quantum vector is length, uvw is
79 // assumed.
80 // <li> <src>MVuvw(Vector<Double></src> creates from angles (less than
81 // or equal to two elements) or x,y,z (3 elements).
82 // <li> <src>MVuvw(Vector<Quantity></src> creates from length+angles,
83 // angles, or x,y,z, depending on units.
84 // <li> <src>MVuvw(MVBaseline, MVDirection)</src> creates a uvw
85 // in the specified reference direction (in same reference frame)
86 // </ul>
87 // A void adjust(Double) function normalises the vector to a length of 1;
88 // a get() returns as a
89 // Double 3-vector the length and angles of the uvw vector;
90 // a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated
91 // element, and getValue returns the vector.<br>
92 // uvws can be added and subtracted.<br>
93 // The multiplication of two uvws produces the in-product.<br>
94 // </synopsis>
95 //
96 // <example>
97 // See <linkto class=Muvw>Muvw</linkto> class.
98 // </example>
99 //
100 // <motivation>
101 // To do coordinate transformations
102 // </motivation>
103 //
104 // <todo asof="1998/04/20">
105 // <li> Implement for EW
106 // <li> Get sign (especially of V) correct
107 // <li> Let it handle Vectors of UVW
108 // <li> Add some rotation matrix history for speed
109 // </todo>
110 
111 class MVuvw : public MVPosition {
112 
113 public:
114 
115  //# Friends
116 
117  //# Constructors
118  // Default constructor generates a (0,0,0) uvw
119  MVuvw();
120  // Creates from an MVPosition
121  MVuvw(const MVPosition &other);
122  // Creates a specified vector
123  MVuvw(Double in0, Double in1, Double in2);
124  // Creates a vector with specified length towards pole
125  // <group>
126  explicit MVuvw(Double in0);
127  MVuvw(const Quantity &l);
128  // </group>
129  // Creates the uvw from specified (azimuth,elevation) angles and length
130  MVuvw(const Quantity &l, Double angle0, Double angle1);
131  // Creates the uvw from specified angles and length. or uvws
132  // <thrown>
133  // <li> AipsError if quantities not in angle format
134  // </thrown>
135  // <group>
136  MVuvw(const Quantity &l, const Quantity &angle0,
137  const Quantity &angle1);
138  // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
139  MVuvw(const Quantum<Vector<Double> > &angle);
140  MVuvw(const Quantity &l, const Quantum<Vector<Double> > &angle);
141  // </group>
142  // Create from specified length and/or angles and/or uvw
143  // <group>
144  MVuvw(const Vector<Double> &other);
145  MVuvw(const Vector<Quantity> &other);
146  // </group>
147  // uvw from a baseline and a reference direction (in same frame)
148  // <group>
149  MVuvw(const MVBaseline &pos, const MVDirection &dr, Bool ew=False);
150  // </group>
151 
152  //# Operators
153  // Multiplication defined as in-product
154  // <group>
155  Double operator*(const MVuvw &other) const;
156  // </group>
157 
158  // Equality comparisons
159  // <group>
160  Bool operator== (const MVuvw &other) const;
161  Bool operator!= (const MVuvw &other) const;
162  Bool near(const MVuvw &other, Double tol=1e-13) const;
163  Bool near(const MVuvw &other, Quantity tol) const;
164  Bool nearAbs(const MVuvw &other, Double tol=1e-13) const;
165  // </group>
166 
167  // Addition and subtraction
168  // <group>
169  MVuvw operator-() const;
170  MVuvw &operator+=(const MVuvw &right);
171  MVuvw operator+(const MVuvw &right) const;
172  MVuvw &operator-=(const MVuvw &right);
173  MVuvw operator-(const MVuvw &right) const;
174  // </group>
175 
176  //# General Member Functions
177 
178  // Tell me your type
179  // <group>
180  static void assure(const MeasValue &in);
181  // </group>
182 
183  // Normalise direction aspects by adjusting the length to 1
184  // <group>
185  virtual void adjust();
186  virtual void adjust(Double &res);
187  virtual void readjust(Double res);
188  // </group>
189  // Get radius(i.e. length of vector, in m) of uvw
190  virtual Double radius();
191  // Generate a 3-vector of coordinates (length(m), angles(rad))
192  Vector<Double> get() const;
193  // Generate a 3-vector of x,y,z in m
194  const Vector<Double> &getValue() const;
195  // Generate angle 2-vector (in rad)
197  // and with specified units
198  Quantum<Vector<Double> > getAngle(const Unit &unit) const;
199  // Generate the length
200  Quantity getLength() const;
201  // and generate it with the specified units
202  Quantity getLength(const Unit &unit) const;
203  // Get the uvw angle between the directions. I.e. the angle between
204  // the direction from one to the pole, and from one to the other.
205  // <group>
206  Double uvwAngle(const MVuvw &other) const;
207  Quantity uvwAngle(const MVuvw &other,
208  const Unit &unit) const;
209  // </group>
210  // Get the angular separation between two directions.
211  // <group>
212  Double separation(const MVuvw &other) const;
213  Quantity separation(const MVuvw &other,
214  const Unit &unit) const;
215  // </group>
216  // Produce the cross product
217  MVuvw crossProduct(const MVuvw &other) const;
218 
219  // Print data
220  virtual void print(ostream &os) const;
221  // Clone
222  virtual MeasValue *clone() const;
223 
224  // Get the value in internal units
225  virtual Vector<Double> getVector() const;
226  // Set the value from internal units (set 0 for empty vector)
227  virtual void putVector(const Vector<Double> &in);
228  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
229  // records. The getXRecordValue() gets additional information for records.
230  // Note that the Vectors could be empty.
231  // <group>
232  virtual Vector<Quantum<Double> > getRecordValue() const;
233  virtual Vector<Quantum<Double> > getXRecordValue() const;
235  return getXRecordValue(); } ;
236  // </group>
237  // Set the internal value if correct values and dimensions
238  virtual Bool putValue(const Vector<Quantum<Double> > &in);
239 
240 };
241 
242 //# Global functions
243 // Rotate a uvw vector with rotation matrix and other multiplications
244 // <group>
245 MVuvw operator*(const RotMatrix &left, const MVuvw &right);
246 MVuvw operator*(const MVuvw &left, const RotMatrix &right);
247 MVuvw operator*(Double left, const MVuvw &right);
248 MVuvw operator*(const MVuvw &left, Double right);
249 Double operator*(const Vector<Double> &left, const MVuvw &right);
250 Double operator*(const MVuvw &left, const Vector<Double> &right);
251 Double operator*(const MVPosition &left, const MVuvw &right);
252 Double operator*(const MVuvw &left, const MVPosition &right);
253 // </group>
254 
255 
256 } //# NAMESPACE CASACORE - END
257 
258 #endif
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector&lt;Quantity&gt;.
Bool operator==(const MVuvw &other) const
Equality comparisons.
MVuvw operator-() const
Addition and subtraction.
MVuvw()
Default constructor generates a (0,0,0) uvw.
Bool near(const MVuvw &other, Double tol=1e-13) const
virtual void adjust()
Normalise direction aspects by adjusting the length to 1.
Double uvwAngle(const MVuvw &other) const
Get the uvw angle between the directions.
MVuvw & operator-=(const MVuvw &right)
MVuvw operator+(const MVuvw &right) const
Bool operator!=(const MVuvw &other) const
virtual Vector< Double > getVector() const
Get the value in internal units.
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
defines physical units
Definition: Unit.h:189
A 3D vector on Earth.
Definition: MVBaseline.h:108
Quantity getLength() const
Generate the length.
virtual Vector< Quantum< Double > > getTMRecordValue() const
Definition: MVuvw.h:234
virtual void print(ostream &os) const
Print data.
Base class for values in a Measure.
Definition: MeasValue.h:107
Double separation(const MVuvw &other) const
Get the angular separation between two directions.
virtual Double radius()
Get radius(i.e.
Bool nearAbs(const MVuvw &other, Double tol=1e-13) const
double Double
Definition: aipstype.h:55
Double operator*(const MVuvw &other) const
Multiplication defined as in-product.
virtual void readjust(Double res)
Re-adjust using factor given.
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A 3D vector in space.
Definition: MVPosition.h:113
Quantum< Vector< Double > > getAngle() const
Generate angle 2-vector (in rad)
A 3D vector on Earth.
Definition: MVuvw.h:111
const Bool False
Definition: aipstype.h:44
virtual Vector< Quantum< Double > > getXRecordValue() const
virtual MeasValue * clone() const
Clone.
MVuvw crossProduct(const MVuvw &other) const
Produce the cross product.
const Double e
e and functions thereof:
Vector of three direction cosines.
Definition: MVDirection.h:107
static void assure(const MeasValue &in)
Tell me your type.
MVuvw & operator+=(const MVuvw &right)
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
const Vector< Double > & getValue() const
Generate a 3-vector of x,y,z in m.