LevelS C++ support library  3.83
pointing.h
Go to the documentation of this file.
1 /*
2  * This file is part of libcxxsupport.
3  *
4  * libcxxsupport is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * libcxxsupport is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with libcxxsupport; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
21  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
22  * (DLR).
23  */
24 
25 /*! \file pointing.h
26  * Class representing a direction in 3D space
27  *
28  * Copyright (C) 2003-2012 Max-Planck-Society
29  * \author Martin Reinecke
30  */
31 
32 #ifndef PLANCK_POINTING_H
33 #define PLANCK_POINTING_H
34 
35 #include <cmath>
36 #include "vec3.h"
37 
38 /*! \defgroup pointinggroup Pointings */
39 /*! \{ */
40 
41 /*! Class representing a direction in 3D space or a location on the
42  unit sphere. All angles in radians. */
43 class pointing
44  {
45  public:
46  /*! Colatitude of the pointing (i.e. the North pole is at \a theta=0). */
47  double theta;
48  /*! Longitude of the pointing. */
49  double phi;
50 
51  /*! Default constructor. \a theta and \a phi are not initialized. */
52  pointing() {}
53  /*! Creates a pointing with \a Theta and \a Phi. */
54  pointing (double Theta, double Phi) : theta(Theta), phi(Phi) {}
55 
56 // FIXME: should become "explicit" some time
57  /*! Creates a pointing from the vector \a inp. \a inp need not be
58  normalized. */
59  pointing (const vec3 &inp)
60  { from_vec3(inp); }
61 // FIXME: should be removed some time
62  /*! Returns a normalized vector pointing in the same direction. */
63  operator vec3() const
64  { return to_vec3(); }
65  /*! Returns a normalized vector pointing in the same direction. */
66  vec3 to_vec3() const;
67  /*! Converts \a inp to \a ptg. \a inp need not be normalized. */
68  void from_vec3 (const vec3 &inp);
69  /*! Changes the angles so that \a 0<=theta<=pi. */
70  void normalize_theta();
71  /*! Changes the angles so that \a 0<=theta<=pi and \a 0<=phi<2*pi. */
72  void normalize();
73  };
74 
75 /*! Writes \a p to \a os.
76  \relates pointing */
77 std::ostream &operator<< (std::ostream &os, const pointing &p);
78 
79 /*! \} */
80 
81 #endif
pointing(const vec3 &inp)
Definition: pointing.h:59
pointing(double Theta, double Phi)
Definition: pointing.h:54
void normalize_theta()
Definition: pointing.cc:49
std::ostream & operator<<(std::ostream &os, const pointing &p)
void normalize()
Definition: pointing.cc:58
double phi
Definition: pointing.h:49
vec3_t< float64 > vec3
Definition: vec3.h:143
Definition: vec3.h:43
vec3 to_vec3() const
Definition: pointing.cc:38
pointing()
Definition: pointing.h:52
double theta
Definition: pointing.h:47
void from_vec3(const vec3 &inp)
Definition: pointing.cc:43

Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library