casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MVDirection.h
Go to the documentation of this file.
00001 //# MVDirection.h: Vector of three direction cosines
00002 //# Copyright (C) 1996,1997,1998,1999,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: MVDirection.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_MVDIRECTION_H
00029 #define CASA_MVDIRECTION_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 De
00038 
00039 // <summary> Vector of three direction cosines </summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
00044 // </reviewed>
00045 
00046 // <prerequisite>
00047 //   <li> <linkto class=MVPosition>MVPosition</linkto>
00048 //   <li> <linkto class=Vector>Vector</linkto>
00049 //   <li> <linkto class=Quantum>Quantum</linkto>
00050 // </prerequisite>
00051 //
00052 // <etymology>
00053 // From Measure, Value and Direction
00054 // </etymology>
00055 //
00056 // <synopsis>
00057 // An MVDirection is a 3-vector of direction cosines. It is based on the
00058 // MVposition class. The main difference is that the length of the
00059 // vector will be adjusted (normalised) to a length of 1 in all operations.
00060 // It can be constructed with:
00061 // <ul>
00062 //   <li> MVDirection() creates direction cosines for pole: (0,0,1)
00063 //   <li> MVDirection(MVDirection) creates a copy
00064 //   <li> MVDirection(Double, Double, Double) creates with
00065 //              specified values and adjust to length of 1.
00066 //   <li> MVDirection(Double, Double) creates a MVDirection assuming that the two
00067 //              values are (in radians) angle along 'equator' and towards 'pole'.
00068 //   <li> MVDirection(Quantity, Quantity) creates a MVDirection assuming angles
00069 //              as in previous
00070 //   <li> <src>MVDirection(Quantum<Vector<Double> >)</src> creates an MVDirection
00071 //              from angle vector, assuming
00072 //              second as zero if not present, and pole if length 0. Assumes
00073 //              a direction cosine if 3 elements
00074 //   <li> <src>MVDirection(Vector<Double>)</src> creates an MVDirection with
00075 //              the same restrictions as previous one
00076 //   <li> <src>MVDirection(Vector<Quantum<Double> >)</src> creates an 
00077 //              MVDirection with the same rstrictions as previous one; but
00078 //              with unit check.
00079 // </ul>
00080 // A void adjust() function normalises the vector to a length of 1;
00081 // a get() returns as a
00082 // Double 2-vector the angles of the direction cosines; a getAngle() returns
00083 // a Quantum 2-vector, (uInt) returns the indicated element, and getValue
00084 // returns the direction cosine vector.<br>
00085 // Direction cosines can be added and subtracted: the result will be 
00086 // adjusted to a length of 1.<br>
00087 // The multiplication of two direction cosines produces the inner product.<br>
00088 // shift() methods are available to shift in angular coordinates. E.g.
00089 // shift(Quantity(5, "arcsec"), Quantity(-7, "arcsec")) will shift 5 arcsec
00090 // in longitude, and -7 arcsec in latitude. They have a trueAngle switch
00091 // to shift in latitude and perpendicular (along a great circle) to it.
00092 // </synopsis>
00093 //
00094 // <example>
00095 // See <linkto class=MDirection>MDirection</linkto>
00096 // </example>
00097 //
00098 // <motivation>
00099 // To aid coordinate transformations
00100 // </motivation>
00101 //
00102 // <todo asof="1998/04/22">
00103 //   <li> check if true shifts can be done faster
00104 // </todo>
00105 
00106 class MVDirection : public MVPosition {
00107 
00108 public:
00109 
00110   //# Friends
00111   
00112   //# Constructors
00113   // Default constructor generates a direction to the pole (i.e. (0,0,1))
00114   MVDirection();
00115   // Copy constructor
00116   MVDirection(const MVPosition &other);
00117   // Constructs with elevation = 0.
00118   // <group>
00119   MVDirection(Double in0);
00120   MVDirection(const Quantity &angle0);
00121   // </group>
00122   // Creates a specified vector
00123   MVDirection(Double in0, Double in1, Double in2);
00124   // Creates the direction cosines from specified angles along equator (azimuth)
00125   // and towards pole (,elevation).
00126   MVDirection(Double angle0, Double angle1);
00127   // Creates the direction cosines from specified angles
00128   // <thrown>
00129   //    <li> AipsError if quantities not in angle format
00130   // </thrown>
00131   // <group>
00132   MVDirection(const Quantity &angle0, const Quantity &angle1);
00133   // If not enough angles: pole (=(0,0,1)) assumed (if none), or elevation =0 (if 1);
00134   // direction cosines assumed (if 3).
00135   // <thrown>
00136   //  <li> AipsError if more than 3 values or incorrect units
00137   // </thrown>
00138   MVDirection(const Quantum<Vector<Double> > &angle);
00139   // </group>
00140   // Create from Vector. Assumes angles if less than or equal than 2 elements.
00141   // Assumes direction cosines if 3 elements.
00142   // <thrown>
00143   //  <li> AipsError if more than 3 elements
00144   // </thrown>
00145   // <group>
00146   MVDirection(const Vector<Double> &other);
00147   MVDirection(const Vector<Quantity> &other);
00148   // </group>
00149   // Copy assignment
00150   MVDirection &operator=(const MVDirection &other);
00151   
00152   // Destructor
00153   ~MVDirection();
00154   //# Operators
00155   // Addition and subtraction
00156   // <group>
00157   MVDirection &operator+=(const MVDirection &right);
00158   MVDirection operator+(const MVDirection &right) const;
00159   MVDirection &operator-=(const MVDirection &right);
00160   MVDirection operator-(const MVDirection &right) const;
00161   // </group>
00162   
00163   //# General Member Functions
00164   
00165   // Tell me your type
00166   // <group>
00167   virtual uInt type() const;
00168   static void assure(const MeasValue &in);
00169   // </group>
00170   
00171   // Adjust the direction cosines to a length of 1
00172   virtual void adjust();
00173   // Adjust the direction cosines to a length of 1 and return the length value
00174   virtual void adjust(Double &res);
00175   // Re-adjust : taken from MVPosition.
00176   //
00177   // Clone data
00178   virtual MeasValue *clone() const;
00179   // Generate a 2-vector of angles (in rad)
00180   Vector<Double> get() const;
00181   // Get the latitude angle (rad)
00182   Double getLat() const;
00183   // and with specified units
00184   Quantity getLat(const Unit &unit) const;
00185   // Get the position angle between the directions. I.e. the angle between
00186   // the direction from one to the pole, and from one to the other.
00187   // <group>
00188   Double positionAngle(const MVPosition &other) const;
00189   Double positionAngle(const MVDirection &other) const;
00190   Quantity positionAngle(const MVPosition &other, 
00191                          const Unit &unit) const;
00192   Quantity positionAngle(const MVDirection &other, 
00193                          const Unit &unit) const;
00194   // </group>
00195   // Get the angular separation between two directions.
00196   // <group>
00197   Double separation(const MVPosition &other) const;
00198   Double separation(const MVDirection &other) const;
00199   Quantity separation(const MVPosition &other, 
00200                       const Unit &unit) const;
00201   Quantity separation(const MVDirection &other, 
00202                       const Unit &unit) const;
00203   // </group>
00204   // Produce the cross product
00205   MVDirection crossProduct(const MVDirection &other) const;
00206   // Get the internal value as a <src>Vector<Quantity></src>. Usable in
00207   // records. The getXRecordValue() gets additional information for records.
00208   // Note that the Vectors could be empty.
00209   // <group>
00210   virtual Vector<Quantum<Double> > getRecordValue() const;
00211   virtual Vector<Quantum<Double> > getXRecordValue() const;
00212   virtual Vector<Quantum<Double> > getTMRecordValue() const;
00213   // </group>
00214   // Set the internal value if correct values and dimensions
00215   virtual Bool putValue(const Vector<Quantum<Double> > &in);
00216   // Set the internal value, using the longitude and latitude (in rad) given
00217   void setAngle(Double angle0, Double angle1);
00218   // Shift the direction in longitude (radians if Double) and/or latitude.
00219   // If the trueAngle switch is True, the longitude shift will be in
00220   // angular units perpendicular to the direction to the pole at the shifted
00221   // latitude, along a great circle.
00222   // <group>
00223   void shift(const Quantum<Double> &lng,
00224              const Quantum<Double> &lat, Bool trueAngle=False);
00225   void shift(Double lng, Double lat, Bool trueAngle=False);
00226   void shiftLongitude(const Quantity &lng, Bool trueAngle=False);
00227   void shiftLongitude(Double lng, Bool trueAngle=False);
00228   void shiftLatitude(const Quantum<Double> &lat, Bool trueAngle=False);
00229   void shiftLatitude(Double lat, Bool trueAngle=False);
00230   void shift(const MVDirection &shft, Bool trueAngle=False);
00231   // </group>
00232   // Shift over an angle off in the direction pa. pa is measured from North,
00233   // in the direction of increasing longitude.
00234   // <group>
00235   void shiftAngle(const Quantum<Double> &off,
00236                   const Quantum<Double> &pa);
00237   void shiftAngle(Double off, Double pa);
00238   // </group>
00239   
00240 protected:
00241   //# Data
00242 };
00243 
00244 //# Global functions
00245 // Rotate a position vector
00246 MVDirection operator*(const RotMatrix &left, const MVDirection&right);
00247 MVDirection  operator*(const MVDirection &left, const RotMatrix &right);
00248 
00249 
00250 } //# NAMESPACE CASA - END
00251 
00252 #endif