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