casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Projection.h
Go to the documentation of this file.
00001 //# Projection.h: Geometric parameters needed for a sky projection to a plane
00002 //# Copyright (C) 1997,1998,1999,2000,2001,2003
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 //#
00027 //# $Id: Projection.h 20491 2009-01-16 08:33:56Z gervandiepen $
00028 
00029 #ifndef COORDINATES_PROJECTION_H
00030 #define COORDINATES_PROJECTION_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/Vector.h>
00034 
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 
00037 
00038 // <summary>
00039 //  Geometric parameters needed for a sky projection to a plane
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="Peter Barnes" date="1999/12/24" tests="tProjection">
00045 // </reviewed>
00046 //
00047 // <prerequisite>
00048 //   <li> Knowledge of astronomical coordinate conversions in general. Probably the
00049 //        best documents are the papers by Mark Calabretta and Eric Greisen.
00050 //        The initial draft from 1996 can be found at
00051 //        http://www.atnf.csiro.au/~mcalabre.  It is this draft that the
00052 //        Coordinate classes are based upon.  Since then, this paper has evolved
00053 //        into three which can be found at the above address, and will be published in the
00054 //        Astronomy and Astrophysics Supplement Series (probably in 2000).
00055 //        The design has changed since the initial draft.  When these papers
00056 //        are finalized, and the IAU has ratified the new standards, WCSLIB
00057 //        (Mark Calabretta's implementation of these conventions) will be
00058 //        revised for the new designs.  At that time, the Coordinate classes
00059 //        may also be revised.
00060 // </prerequisite>
00061 //
00062 // <synopsis>
00063 // This class is used to hold:
00064 // <ol>
00065 //    <li> The type of the projection (e.g. SIN); and
00066 //    <li> The parameters of the projection, if any. These parameters are described
00067 //         by Calabretta and Greisen (called PROJP) in the 1996 draft. 
00068 //         In the recent versions, this paper has split into three, and the
00069 //         projection parameters have been reworked into the PV matrix.
00070 //         However, these have not yet been implemented in WCSLIB so we
00071 //         stick with the old ones for now.
00072 // </ol>
00073 // </synopsis>
00074 //
00075 // <example>
00076 // <srcblock>
00077 //    Projection proj(Projection::CAR);
00078 //    cerr << proj.parameters() << endl;
00079 // </srcblock>
00080 // This projection requires no parameters so the printed parameter
00081 // vector would be of zero length.
00082 // </example>
00083 //
00084 // <thrown>
00085 //   <li>  AipsError
00086 // </thrown>
00087 //
00088 // <todo asof="2000/01/01">
00089 //   <li> Worry about projection parameters which are unit dependent (i.e. 
00090 //        radians vs. degrees).
00091 //   <li> LONGPOLE should probably go in here.
00092 // </todo>
00093 // 
00094 
00095 class Projection
00096 {
00097 public:
00098     // Hold all the known types of celestial projections.
00099     enum Type {
00100         // Zenithal/Azimuthal perspective.
00101         AZP,
00102         // Slant zenithal perspective, new
00103         SZP,
00104         // Gnomonic.
00105         TAN, 
00106         // Orthographics/synthesis.
00107         SIN, 
00108         // Stereographic.
00109         STG, 
00110         // zenith/azimuthal equidistant.
00111         ARC, 
00112         // zenithal/azimuthal polynomial.
00113         ZPN, 
00114         // zenithal/azimuthal equal area.
00115         ZEA, 
00116         // Airy.
00117         AIR, 
00118         // Cylindrical perspective.
00119         CYP, 
00120         // Plate carree
00121         CAR, 
00122         // Mercator.
00123         MER, 
00124         // Cylindrical equal area.
00125         CEA,
00126         // Conic perspective.
00127         COP, 
00128         // Conic equidistant.
00129         COD, 
00130         // Conic equal area.
00131         COE, 
00132         // Conic orthomorphic.
00133         COO, 
00134         // Bonne.
00135         BON, 
00136         // Polyconic.
00137         PCO, 
00138         // Sanson-Flamsteed (global sinusoidal).
00139         // The old GLS projection is now SFL. The 'GLS'
00140         // string will be converted to 'SFL'
00141         SFL, 
00142         // Parabolic.
00143         PAR, 
00144         // Hammer-Aitoff.
00145         AIT, 
00146         // Mollweide.
00147         MOL, 
00148         // COBE quadrilateralized spherical cube.
00149         CSC, 
00150         // Quadrilateralized spherical cube.
00151         QSC,
00152         // Tangential spherical cube.
00153         TSC,
00154         // HEALPix grid
00155         HPX, 
00156         // N_PROJ gives the number of supported projections - it shouldn't be used
00157         // as a projection
00158         N_PROJ };
00159 
00160     // Construct a projection which needs no parameters. SIN is unique in that
00161     // it can be created with 0 or 2 parameters.
00162     Projection(Projection::Type which=CAR);
00163 
00164     // Construct a projection from FITS CTYPE keywords
00165     Projection(const String& ctypeLin, const String& ctypeLat,
00166                const Vector<Double>& parameters);
00167 
00168     // Construct a projection which needs parameters. The parameter vector must be
00169     // the length of the required number of parameters.
00170     Projection(Projection::Type which, const Vector<Double> &parameters);
00171 
00172     // Copy constructor (copy semantics).
00173     Projection(const Projection &other);
00174 
00175     // Assignment (copy semantics)
00176     Projection &operator=(const Projection &other);
00177 
00178     // Destructor
00179     ~Projection();
00180 
00181     // What is the Type of this projection?
00182     Projection::Type type() const;
00183 
00184     // What is the type of this projection as a String (e.g. "SIN").
00185     // <group>
00186     String name() const;
00187     static String name(Projection::Type proj);
00188     // </group>
00189 
00190     // Turn a projection type name into a Type. 
00191     // Returns N_PROJ if the projection is not known.
00192     static Projection::Type type(const String &name);
00193 
00194     // How many parameters does this projection have at most?
00195     // What is the minimum number of parameters that have to be supplied?
00196     // What are the parameter values?
00197     // <group>
00198     static uInt nParameters(Projection::Type proj);
00199     static uInt nMinParameters(Projection::Type proj);
00200     const Vector<Double> &parameters() const;
00201     // </group>
00202 
00203     // Comparison to fractional tolerance. 
00204     Bool near(const Projection &other, Double tol=1.0e-6) const;
00205 
00206     // Is this projection a 'zenithal' projection
00207     static Bool isZenithal (Projection::Type proj);
00208 
00209 private:
00210     Projection::Type which_p;
00211     Vector<Double> parameters_p;
00212 
00213     void validate(const Bool verbose=False);
00214     Projection::Type type (String& ctypeLong, String& ctypeLat) const;
00215 };
00216 
00217 //#---------- Inlines --------------------------------------------------------------
00218 inline Projection::Type Projection::type() const {return which_p;}
00219 inline const Vector<Double> & Projection::parameters() const {return parameters_p;}
00220 
00221 } //# NAMESPACE CASA - END
00222 
00223 #endif
00224