casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVuvw.h
Go to the documentation of this file.
00001 //# MVuvw.h: A 3D vector on Earth
00002 //# Copyright (C) 1998,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: MVuvw.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVUVW_H
00029 #define CASA_MVUVW_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/Quanta/MVPosition.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 //# Forward Declarations
00038 class MVDirection;
00039 class MVBaseline;
00040 
00041 // <summary> A 3D vector on Earth </summary>
00042 
00043 // <use visibility=export>
00044 
00045 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMuvw" demos="">
00046 // </reviewed>
00047 
00048 // <prerequisite>
00049 //   <li> <linkto class=MeasValue>MeasValue</linkto>
00050 // </prerequisite>
00051 //
00052 // <etymology>
00053 // From Measure, Value and uvw
00054 // </etymology>
00055 //
00056 // <synopsis>
00057 // A MVuvw is a 3-vector of uvws in a rectangular frame with
00058 // internal units of m.<br>
00059 // It can be constructed with:
00060 // <ul>
00061 //   <li> MVuvw() creates point at origin (0,0,0)
00062 //   <li> MVuvw(MVuvw) creates a copy
00063 //   <li> MVuvw(Double, Double, Double) creates (x,y,z) with
00064 //              specified values (assuming meters)
00065 //   <li> MVuvw(Quantity length,Double, Double) creates a MVuvw assuming
00066 //              that the two values are (in radians) angle along 'equator' 
00067 //              and towards 'pole'.
00068 //   <li> MVuvw(Quantity length, Quantity, Quantity) creates a MVuvw 
00069 //              assuming angles as in previous, or uvws
00070 //   <li> <src>MVuvw(Quantity, Quantum<Vector<Double> >)</src> creates a 
00071 //              MVuvw from angle vector, using first two angles, and 
00072 //              assuming second as zero if not present.
00073 //   <li> <src>MVuvw(Quantum<Vector<Double> ></src> creates from
00074 //              angles or uvws, depending on the units in the
00075 //              quantum vector. In the angle case,
00076 //              the data derived can be scaled with the readjust() function. If
00077 //              the unit of the quantum vector is length, uvw is
00078 //              assumed.
00079 //    <li> <src>MVuvw(Vector<Double></src> creates from angles (less than
00080 //              or equal to two elements) or x,y,z (3 elements).
00081 //    <li> <src>MVuvw(Vector<Quantity></src> creates from length+angles,
00082 //              angles, or x,y,z, depending on units.
00083 //    <li> <src>MVuvw(MVBaseline, MVDirection)</src> creates a uvw
00084 //              in the specified reference direction (in same reference frame)
00085 // </ul>
00086 // A void adjust(Double) function normalises the vector to a length of 1;
00087 // a get() returns as a
00088 // Double 3-vector the length and angles of the uvw vector;
00089 // a getAngle() returns a Quantum 2-vector, (uInt) returns the indicated 
00090 // element, and getValue returns the vector.<br>
00091 // uvws can be added and subtracted.<br>
00092 // The multiplication of two uvws produces the in-product.<br>
00093 // </synopsis>
00094 //
00095 // <example>
00096 // See <linkto class=Muvw>Muvw</linkto> class.
00097 // </example>
00098 //
00099 // <motivation>
00100 // To do coordinate transformations
00101 // </motivation>
00102 //
00103 // <todo asof="1998/04/20">
00104 //      <li> Implement for EW
00105 //      <li> Get sign (especially of V) correct
00106 //      <li> Let it handle Vectors of UVW
00107 //      <li> Add some rotation matrix history for speed
00108 // </todo>
00109 
00110 class MVuvw : public MVPosition {       
00111 
00112 public:
00113 
00114   //# Friends
00115   
00116   //# Constructors
00117   // Default constructor generates a (0,0,0) uvw
00118   MVuvw();
00119   // Copy constructor
00120   MVuvw(const MVPosition &other);
00121   // Creates a specified vector
00122   MVuvw(Double in0, Double in1, Double in2);
00123   // Creates a vector with specified length towards pole
00124   // <group>
00125   explicit MVuvw(Double in0);
00126   MVuvw(const Quantity &l);
00127   // </group>
00128   // Creates the uvw from specified (azimuth,elevation) angles and length
00129   MVuvw(const Quantity &l, Double angle0, Double angle1);
00130   // Creates the uvw from specified angles and length. or uvws
00131   // <thrown>
00132   //    <li> AipsError if quantities not in angle format
00133   // </thrown>
00134   // <group>
00135   MVuvw(const Quantity &l, const Quantity &angle0, 
00136              const Quantity &angle1);
00137   // If not enough angles: pole assumed (if none), or elevation =0 (if 1)
00138   MVuvw(const Quantum<Vector<Double> > &angle);
00139   MVuvw(const Quantity &l, const Quantum<Vector<Double> > &angle);
00140   // </group>
00141   // Create from specified length and/or angles and/or uvw
00142   // <group>
00143   MVuvw(const Vector<Double> &other);
00144   MVuvw(const Vector<Quantity> &other);
00145   // </group>
00146   // uvw from a baseline and a reference direction (in same frame)
00147   // <group>
00148   MVuvw(const MVBaseline &pos, const MVDirection &dr, Bool ew=False);
00149   // </group>
00150   // Copy assignment
00151   MVuvw &operator=(const MVuvw &other);
00152   
00153   // Destructor
00154   ~MVuvw();
00155   
00156   //# Operators
00157   // Multiplication defined as in-product
00158   // <group>
00159   Double operator*(const MVuvw &other) const;
00160   // </group>
00161   
00162   // Equality comparisons
00163   // <group>
00164   Bool operator== (const MVuvw &other) const;
00165   Bool operator!= (const MVuvw &other) const;
00166   Bool near(const MVuvw &other, Double tol=1e-13) const;
00167   Bool near(const MVuvw &other, Quantity tol) const;
00168   Bool nearAbs(const MVuvw &other, Double tol=1e-13) const;
00169   // </group>
00170   
00171   // Addition and subtraction
00172   // <group>
00173   MVuvw operator-() const;
00174   MVuvw &operator+=(const MVuvw &right);
00175   MVuvw operator+(const MVuvw &right) const;
00176   MVuvw &operator-=(const MVuvw &right);
00177   MVuvw operator-(const MVuvw &right) const;
00178   // </group>
00179   
00180   //# General Member Functions
00181   
00182   // Tell me your type
00183   // <group>
00184   virtual uInt type() const;
00185   static void assure(const MeasValue &in);
00186   // </group>
00187   
00188   // Normalise direction aspects by adjusting the length to 1
00189   // <group>
00190   virtual void adjust();
00191   virtual void adjust(Double &res);
00192   virtual void readjust(Double res);
00193   // </group>
00194   // Get radius(i.e. length of vector, in m) of uvw
00195   virtual Double radius();
00196   // Generate a 3-vector of coordinates (length(m), angles(rad))
00197   Vector<Double> get() const;
00198   // Generate a 3-vector of x,y,z in m
00199   const Vector<Double> &getValue() const;
00200   // Generate angle 2-vector (in rad)
00201   Quantum<Vector<Double> > getAngle() const;
00202   // and with specified units
00203   Quantum<Vector<Double> > getAngle(const Unit &unit) const;
00204   // Generate the length
00205   Quantity getLength() const;
00206   // and generate it with the specified units
00207   Quantity getLength(const Unit &unit) const;
00208   // Get the uvw angle between the directions. I.e. the angle between
00209   // the direction from one to the pole, and from one to the other.
00210   // <group>
00211   Double uvwAngle(const MVuvw &other) const;
00212   Quantity uvwAngle(const MVuvw &other, 
00213                          const Unit &unit) const;
00214   // </group>
00215   // Get the angular separation between two directions.
00216   // <group>
00217   Double separation(const MVuvw &other) const;
00218   Quantity separation(const MVuvw &other, 
00219                       const Unit &unit) const;
00220   // </group>
00221   // Produce the cross product
00222   MVuvw crossProduct(const MVuvw &other) const;
00223   
00224   // Print data
00225   virtual void print(ostream &os) const;
00226   // Clone
00227   virtual MeasValue *clone() const;
00228 
00229   // Get the value in internal units
00230   virtual Vector<Double> getVector() const;
00231   // Set the value from internal units (set 0 for empty vector)
00232   virtual void putVector(const Vector<Double> &in);
00233   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00234   // records. The getXRecordValue() gets additional information for records.
00235   // Note that the Vectors could be empty.
00236   // <group>
00237   virtual Vector<Quantum<Double> > getRecordValue() const;
00238   virtual Vector<Quantum<Double> > getXRecordValue() const;
00239   virtual Vector<Quantum<Double> > getTMRecordValue() const {
00240     return getXRecordValue(); } ;
00241   // </group>
00242   // Set the internal value if correct values and dimensions
00243   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00244   
00245 };
00246 
00247 //# Global functions
00248 // Rotate a uvw vector with rotation matrix and other multiplications
00249 // <group>
00250 MVuvw operator*(const RotMatrix &left, const MVuvw &right);
00251 MVuvw operator*(const MVuvw &left, const RotMatrix &right);
00252 MVuvw operator*(Double left, const MVuvw &right);
00253 MVuvw operator*(const MVuvw &left, Double right);
00254 Double operator*(const Vector<Double> &left, const MVuvw &right);
00255 Double operator*(const MVuvw &left, const Vector<Double> &right);
00256 Double operator*(const MVPosition &left, const MVuvw &right);
00257 Double operator*(const MVuvw &left, const MVPosition &right);
00258 // </group>
00259 
00260 
00261 } //# NAMESPACE CASA - END
00262 
00263 #endif