|
SISCone
2.0.5
|
00001 // -*- C++ -*- 00003 // File: geom_2d.h // 00004 // Description: header file for two-dimensional geometry tools // 00005 // This file is part of the SISCone project. // 00006 // WARNING: this is not the main SISCone trunk but // 00007 // an adaptation to spherical coordinates // 00008 // For more details, see http://projects.hepforge.org/siscone // 00009 // // 00010 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez // 00011 // // 00012 // This program is free software; you can redistribute it and/or modify // 00013 // it under the terms of the GNU General Public License as published by // 00014 // the Free Software Foundation; either version 2 of the License, or // 00015 // (at your option) any later version. // 00016 // // 00017 // This program is distributed in the hope that it will be useful, // 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 00020 // GNU General Public License for more details. // 00021 // // 00022 // You should have received a copy of the GNU General Public License // 00023 // along with this program; if not, write to the Free Software // 00024 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 00025 // // 00026 // $Revision:: 268 $// 00027 // $Date:: 2009-03-12 21:24:16 +0100 (Thu, 12 Mar 2009) $// 00029 00030 #ifndef __SPH_GEOM_2D_H__ 00031 #define __SPH_GEOM_2D_H__ 00032 00033 #include <iostream> 00034 #include <math.h> 00035 #include <siscone/defines.h> 00036 #include <siscone/geom_2d.h> 00037 00038 #ifndef M_PI 00039 #define M_PI 3.141592653589793238462643383279502884197 00040 #endif 00041 00042 namespace siscone_spherical{ 00043 00052 class CSphtheta_phi_range{ 00053 public: 00055 CSphtheta_phi_range(); 00056 00062 CSphtheta_phi_range(double c_theta, double c_phi, double R); 00063 00066 CSphtheta_phi_range& operator = (const CSphtheta_phi_range &r); 00067 00072 int add_particle(const double theta, const double phi); 00073 00075 unsigned int theta_range; 00076 00078 unsigned int phi_range; 00079 00081 static double theta_min; 00082 static double theta_max; 00083 00084 private: 00086 inline unsigned int get_theta_cell(double theta){ 00087 return (unsigned int) (1 << ((int) (32*((theta-theta_min)/(theta_max-theta_min))))); 00088 } 00089 00091 inline unsigned int get_phi_cell(double phi){ 00092 return (unsigned int) (1 << ((int) (32*phi/twopi+16)%32)); 00093 } 00094 }; 00095 00100 bool is_range_overlap(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2); 00101 00107 const CSphtheta_phi_range range_union(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2); 00108 00109 } 00110 00111 #endif