SISCone  2.0.6
geom_2d.h
1 // -*- C++ -*-
3 // File: geom_2d.h //
4 // Description: header file for two-dimensional geometry tools //
5 // This file is part of the SISCone project. //
6 // WARNING: this is not the main SISCone trunk but //
7 // an adaptation to spherical coordinates //
8 // For more details, see http://projects.hepforge.org/siscone //
9 // //
10 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez //
11 // //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
16 // //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details. //
21 // //
22 // You should have received a copy of the GNU General Public License //
23 // along with this program; if not, write to the Free Software //
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA //
25 // //
26 // $Revision:: 268 $//
27 // $Date:: 2009-03-12 21:24:16 +0100 (Thu, 12 Mar 2009) $//
29 
30 #ifndef __SPH_GEOM_2D_H__
31 #define __SPH_GEOM_2D_H__
32 
33 #include <iostream>
34 #include <math.h>
35 #include <siscone/defines.h>
36 #include <siscone/geom_2d.h>
37 
38 #ifndef M_PI
39 #define M_PI 3.141592653589793238462643383279502884197
40 #endif
41 
42 namespace siscone_spherical{
43 
53 public:
56 
62  CSphtheta_phi_range(double c_theta, double c_phi, double R);
63 
67 
72  int add_particle(const double theta, const double phi);
73 
75  unsigned int theta_range;
76 
78  unsigned int phi_range;
79 
81  static double theta_min;
82  static double theta_max;
83 
84 private:
86  inline unsigned int get_theta_cell(double theta){
87  return (unsigned int) (1 << ((int) (32*((theta-theta_min)/(theta_max-theta_min)))));
88  }
89 
91  inline unsigned int get_phi_cell(double phi){
92  return (unsigned int) (1 << ((int) (32*phi/twopi+16)%32));
93  }
94 };
95 
100 bool is_range_overlap(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2);
101 
107 const CSphtheta_phi_range range_union(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2);
108 
109 }
110 
111 #endif
static double theta_max
maximal value for theta (set to pi)
Definition: geom_2d.h:82
const double twopi
definition of 2*M_PI which is useful a bit everyhere!
Definition: defines.h:114
class for holding a covering range in eta-phi
Definition: geom_2d.h:52
static double theta_min
extremal value for theta
Definition: geom_2d.h:81
unsigned int theta_range
theta range as a binary coding of covered cells
Definition: geom_2d.h:75
unsigned int phi_range
phi range as a binary coding of covered cells
Definition: geom_2d.h:78
int add_particle(const double theta, const double phi)
add a particle to the range
Definition: geom_2d.cpp:128
CSphtheta_phi_range & operator=(const CSphtheta_phi_range &r)
assignment of range
Definition: geom_2d.cpp:116
The SISCone project has been developed by Gavin Salam and Gregory Soyez
Documentation generated on Sat Oct 24 2015 19:36:13 for SISCone by  Doxygen 1.8.9.1