SISCone  3.0.5
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:: 422 $//
27 // $Date:: 2020-04-22 11:51:09 +0200 (Wed, 22 Apr 2020) $//
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  if (theta>=theta_max) return 1u<<31;
88  return (unsigned int) (1u << ((int) (32*((theta-theta_min)/(theta_max-theta_min)))));
89  }
90 
92  inline unsigned int get_phi_cell(double phi){
93  return (unsigned int) (1u << ((int) (32*phi/twopi+16)%32));
94  }
95 };
96 
101 bool is_range_overlap(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2);
102 
108 const CSphtheta_phi_range range_union(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2);
109 
110 }
111 
112 #endif
class for holding a covering range in eta-phi
Definition: geom_2d.h:52
int add_particle(const double theta, const double phi)
add a particle to the range
Definition: geom_2d.cpp:130
CSphtheta_phi_range & operator=(const CSphtheta_phi_range &r)
assignment of range
Definition: geom_2d.cpp:118
static double theta_max
maximal value for theta (set to pi)
Definition: geom_2d.h:82
unsigned int theta_range
theta range as a binary coding of covered cells
Definition: geom_2d.h:75
static double theta_min
extremal value for theta
Definition: geom_2d.h:81
unsigned int phi_range
phi range as a binary coding of covered cells
Definition: geom_2d.h:78
const double twopi
definition of 2*M_PI which is useful a bit everyhere!
Definition: defines.h:114