casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GaussianConvert.h
Go to the documentation of this file.
00001 //# GaussianConvert.h: Class to convert units of Gaussians from pixel to world 
00002 //# Copyright (C) 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: GaussianConvert.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef COORDINATES_GAUSSIANCONVERT_H
00029 #define COORDINATES_GAUSSIANCONVERT_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <coordinates/Coordinates/CoordinateSystem.h>
00035 #include <components/ComponentModels/GaussianBeam.h>
00036 
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 template<class T> class Quantum;
00041 
00042 
00043 // <summary>
00044 // Converts Gaussian parameters between pixel and world
00045 // </summary>
00046 
00047 // <use visibility=export>
00048 
00049 // <reviewed reviewer="" date="" tests="">
00050 // </reviewed>
00051 
00052 // <prerequisite>
00053 //   <li> <linkto class=CoordinateSystem>CoordinateSystem</linkto>
00054 // </prerequisite>
00055 
00056 // <synopsis> 
00057 // Converts Gaussian parameters between world and pixel. 
00058 // In the pixel coordinate system ([0,0] in center of image)
00059 // the position angle is positive +y to -x. This is consistent
00060 // with Gaussian2D.  In the world coordinate system the pa
00061 // is positive N through E
00062 // </synopsis> 
00063 
00064 // <example>
00065 // <srcblock>
00066 // </srcblock>
00067 // </example>
00068 
00069 // <todo asof="1998/12/11">
00070 //  <li> Position angle signs require more thinking in aips++
00071 // </todo>
00072 
00073 class GaussianConvert
00074 {
00075 public:
00076 
00077     // Default constructor
00078     GaussianConvert ();
00079 
00080     // Constructor.  You specify which world axes (must be length 2)
00081     // of the coordinate system are the relevant ones for
00082     // your gaussian (x then y)
00083     GaussianConvert (const CoordinateSystem& cSys, 
00084                      const Vector<uInt>& worldAxes);
00085 
00086     // Destructor
00087    ~GaussianConvert ();
00088 
00089     // Copy constructor.  Uses copy semantics.
00090     GaussianConvert(const GaussianConvert& other);
00091  
00092     // Assignment operator. Uses copy semantics.
00093     GaussianConvert& operator=(const GaussianConvert& other);
00094 
00095     // (Re)set the coordinate system 
00096     void setCoordinateSystem (const CoordinateSystem& cSys);
00097 
00098     // Re(set) the world axes 
00099     void setWorldAxes (const Vector<uInt>& worldAxes);
00100 
00101     // Convert Gaussian parameters from pixels to world.  Returns
00102     // False if it fails with an error message recoverable with
00103     // function errorMessage.  If you set the units of the output
00104     // axis quanta they will be honoured, otherwise they will come out
00105     // in the axis units of the coordinate system.  For the output position angle,
00106     // if the output units are not set, the units of the input position angle
00107     // will be used.
00108     Bool toWorld(Quantum<Double>& majorAxisOut, Quantum<Double>& minorAxisOut,
00109                  Quantum<Double>& positionAngleOut, Double majorAxisIn,
00110                  Double minorAxisIn, const Quantum<Double>& positionAngleIn);
00111 
00112     // Convert Gaussian parameters from world to pixel.  Returns
00113     // False if it fails with an error message recoverable with
00114     // function errorMessage. For the output position angle,
00115     // if the output units are not set, the units of the input position angle
00116     // will be used.
00117     Bool toPixel(Double& majorAxisOut, Double& minorAxisOut,
00118                  Quantum<Double>& positionAngleOut, const Quantum<Double>& majorAxisIn,
00119                  const Quantum<Double>& minorAxisIn, const Quantum<Double>& positionAngleIn);
00120 
00121     // Convert location
00122     // <group>
00123     Bool toPixel(Vector<Double>& pixel,
00124                  const Vector<Quantum<Double> >& world);
00125     Bool toWorld(Vector<Quantum<Double> >& world,
00126                  const Vector<Double>& pixel);
00127     // </group>
00128 
00129     // Recover error messages from the conversion functions
00130     String errorMessage() const {return itsErrorMessage;}
00131 
00132 
00133 private:
00134 
00135    CoordinateSystem itsCSys;
00136    Vector<uInt> itsWorldAxes;
00137    String itsErrorMessage;
00138    Bool itsValid;
00139 
00140    void convertAxes (Double& minorAxisOut, Double& majorAxisOut,
00141                      Quantum<Double>& positionAngleOut,
00142                      Double minorAxisIn, Double majorAxisIn,
00143                      const Quantum<Double>& positionAngleIn,
00144                      const CoordinateSystem& cSys,
00145                      String dir);
00146 
00147    void checkCoordinateSystem();
00148 
00149    void checkWorldAxes();
00150 
00151    Double positionAngleRange(Double pa);
00152 
00153 };
00154 
00155 
00156 } //# NAMESPACE CASA - END
00157 
00158 #endif