![]() |
|
|||
File indexing completed on 2025-02-22 10:55:44
0001 // -*- C++ -*- 0002 /////////////////////////////////////////////////////////////////////////////// 0003 // File: geom_2d.h // 0004 // Description: header file for two-dimensional geometry tools // 0005 // This file is part of the SISCone project. // 0006 // WARNING: this is not the main SISCone trunk but // 0007 // an adaptation to spherical coordinates // 0008 // For more details, see http://projects.hepforge.org/siscone // 0009 // // 0010 // Copyright (c) 2006-2008 Gavin Salam and Gregory Soyez // 0011 // // 0012 // This program is free software; you can redistribute it and/or modify // 0013 // it under the terms of the GNU General Public License as published by // 0014 // the Free Software Foundation; either version 2 of the License, or // 0015 // (at your option) any later version. // 0016 // // 0017 // This program is distributed in the hope that it will be useful, // 0018 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 0019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 0020 // GNU General Public License for more details. // 0021 // // 0022 // You should have received a copy of the GNU General Public License // 0023 // along with this program; if not, write to the Free Software // 0024 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA // 0025 // // 0026 // $Revision:: $// 0027 // $Date:: $// 0028 /////////////////////////////////////////////////////////////////////////////// 0029 0030 #ifndef __SPH_GEOM_2D_H__ 0031 #define __SPH_GEOM_2D_H__ 0032 0033 #include <iostream> 0034 #include <math.h> 0035 #include <siscone/defines.h> 0036 #include <siscone/geom_2d.h> 0037 0038 #ifndef M_PI 0039 #define M_PI 3.141592653589793238462643383279502884197 0040 #endif 0041 0042 namespace siscone_spherical{ 0043 0044 /** 0045 * \class CSphtheta_phi_range 0046 * \brief class for holding a covering range in eta-phi 0047 * 0048 * This class deals with ranges in the eta-phi plane. It 0049 * implements methods to test if two ranges overlap and 0050 * to take the union of two overlapping intervals. 0051 */ 0052 class CSphtheta_phi_range{ 0053 public: 0054 /// default ctor 0055 CSphtheta_phi_range(); 0056 0057 /// ctor with initialisation 0058 /// we initialise with a centre (in theta,phi) and a radius 0059 /// \param c_theta theta coordinate of the centre 0060 /// \param c_phi phi coordinate of the centre 0061 /// \param R radius 0062 CSphtheta_phi_range(double c_theta, double c_phi, double R); 0063 0064 /// assignment of range 0065 /// \param r range to assign to current one 0066 CSphtheta_phi_range& operator = (const CSphtheta_phi_range &r); 0067 0068 /// add a particle to the range 0069 /// \param theta theta coordinate of the particle 0070 /// \param phi phi coordinate of the particle 0071 /// \return 0 on success, 1 on error 0072 int add_particle(const double theta, const double phi); 0073 0074 /// theta range as a binary coding of covered cells 0075 unsigned int theta_range; 0076 0077 /// phi range as a binary coding of covered cells 0078 unsigned int phi_range; 0079 0080 /// extremal value for theta 0081 static double theta_min; ///< minimal value for theta (set to 0) 0082 static double theta_max; ///< maximal value for theta (set to pi) 0083 0084 private: 0085 /// return the cell index corrsponding to a theta value 0086 inline unsigned int get_theta_cell(double theta){ 0087 if (theta>=theta_max) return 1u<<31; 0088 return (unsigned int) (1u << ((int) (32*((theta-theta_min)/(theta_max-theta_min))))); 0089 } 0090 0091 /// return the cell index corrsponding to a phi value 0092 inline unsigned int get_phi_cell(double phi){ 0093 return (unsigned int) (1u << ((int) (32*phi/twopi+16)%32)); 0094 } 0095 }; 0096 0097 /// test overlap 0098 /// \param r1 first range 0099 /// \param r2 second range 0100 /// \return true if overlap, false otherwise. 0101 bool is_range_overlap(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2); 0102 0103 /// compute union 0104 /// Note: we assume that the two intervals overlap 0105 /// \param r1 first range 0106 /// \param r2 second range 0107 /// \return union of the two ranges 0108 const CSphtheta_phi_range range_union(const CSphtheta_phi_range &r1, const CSphtheta_phi_range &r2); 0109 0110 } 0111 0112 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |