pointing.h

Go to the documentation of this file.
00001 /*
00002  *  This file is part of libcxxsupport.
00003  *
00004  *  libcxxsupport is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  libcxxsupport is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with libcxxsupport; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  */
00018 
00019 /*
00020  *  libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
00021  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00022  *  (DLR).
00023  */
00024 
00025 /*! \file pointing.h
00026  *  Class representing a direction in 3D space
00027  *
00028  *  Copyright (C) 2003-2012 Max-Planck-Society
00029  *  \author Martin Reinecke
00030  */
00031 
00032 #ifndef PLANCK_POINTING_H
00033 #define PLANCK_POINTING_H
00034 
00035 #include <cmath>
00036 #include "vec3.h"
00037 
00038 /*! \defgroup pointinggroup Pointings */
00039 /*! \{ */
00040 
00041 /*! Class representing a direction in 3D space or a location on the
00042     unit sphere. All angles in radians. */
00043 class pointing
00044   {
00045   public:
00046     /*! Colatitude of the pointing (i.e. the North pole is at \a theta=0). */
00047     double theta;
00048     /*! Longitude of the pointing. */
00049     double phi;
00050 
00051     /*! Default constructor. \a theta and \a phi are not initialized. */
00052     pointing() {}
00053     /*! Creates a pointing with \a Theta and \a Phi. */
00054     pointing (double Theta, double Phi) : theta(Theta), phi(Phi) {}
00055 
00056 // FIXME: should become "explicit" some time
00057     /*! Creates a pointing from the vector \a inp. \a inp need not be
00058         normalized. */
00059     pointing (const vec3 &inp)
00060       { from_vec3(inp); }
00061 // FIXME: should be removed some time
00062     /*! Returns a normalized vector pointing in the same direction. */
00063     operator vec3() const
00064       { return to_vec3(); }
00065     /*! Returns a normalized vector pointing in the same direction. */
00066     vec3 to_vec3() const;
00067     /*! Converts \a inp to \a ptg. \a inp need not be normalized. */
00068     void from_vec3 (const vec3 &inp);
00069     /*! Changes the angles so that \a 0<=theta<=pi. */
00070     void normalize_theta();
00071     /*! Changes the angles so that \a 0<=theta<=pi and \a 0<=phi<2*pi. */
00072     void normalize();
00073   };
00074 
00075 /*! Writes \a p to \a os.
00076     \relates pointing */
00077 std::ostream &operator<< (std::ostream &os, const pointing &p);
00078 
00079 /*! \} */
00080 
00081 #endif

Generated on Thu Oct 8 14:48:51 2015 for LevelS C++ support library