32 #ifndef HEALPIX_BASE_H    33 #define HEALPIX_BASE_H    41 template<
typename I> 
struct Orderhelper__ {};
    42 template<> 
struct Orderhelper__<int> {
enum{omax=13};};
    43 template<> 
struct Orderhelper__<int64> {
enum{omax=29};};
    53     I npface_, ncap_, npix_;
    54     double fact1_, fact2_;
    61     void in_ring (I iz, 
double phi0, 
double dphi, rangeset<I> &pixset) 
const;
    63     template<
typename I2> 
void query_multidisc (
const arr<vec3> &norm,
    64       const arr<double> &rad, 
int fact, rangeset<I2> &pixset) 
const;
    66     void query_multidisc_general (
const arr<vec3> &norm, 
const arr<double> &rad,
    67       bool inclusive, 
const std::vector<int> &cmds, rangeset<I> &pixset) 
const;
    69     void query_strip_internal (
double theta1, 
double theta2, 
bool inclusive,
    70       rangeset<I> &pixset) 
const;
    72     inline I spread_bits (
int v) 
const;
    73     inline int compress_bits (I v) 
const;
    75     I xyf2nest(
int ix, 
int iy, 
int face_num) 
const;
    76     void nest2xyf(I pix, 
int &ix, 
int &iy, 
int &face_num) 
const;
    77     I xyf2ring(
int ix, 
int iy, 
int face_num) 
const;
    78     void ring2xyf(I pix, 
int &ix, 
int &iy, 
int &face_num) 
const;
    80     I loc2pix (
double z, 
double phi, 
double sth, 
bool have_sth) 
const;
    81     void pix2loc (I pix, 
double &z, 
double &phi, 
double &sth, 
bool &have_sth)
    84     void xyf2loc(
double x, 
double y, 
int face, 
double &z, 
double &ph,
    85       double &sth, 
bool &have_sth) 
const;
    87     I nest_peano_helper (I pix, 
int dir) 
const;
    92     enum {order_max=Orderhelper__<I>::omax};
   106       { 
Set (order, scheme); }
   120     double ring2z (I ring) 
const;
   124     I xyf2pix(
int ix, 
int iy, 
int face_num)
 const   127         xyf2ring(ix,iy,face_num) : xyf2nest(ix,iy,face_num);
   129     void pix2xyf(I pix, 
int &ix, 
int &iy, 
int &face_num)
 const   132         ring2xyf(pix,ix,iy,face_num) : nest2xyf(pix,ix,iy,face_num);
   148       { 
return loc2pix(z,phi,0.,
false); }
   154       const double pi_=3.141592653589793238462643383279502884197;
   155       planck_assert((ang.theta>=0)&&(ang.theta<=pi_),
"invalid theta value");
   156       return ((ang.theta<0.01) || (ang.theta > 3.14159-0.01)) ?
   157         loc2pix(cos(ang.theta),ang.phi,sin(ang.theta),
true) :
   158         loc2pix(cos(ang.theta),ang.phi,0.,
false);
   164       double xl = 1./vec.Length();
   165       double phi = safe_atan2(vec.y,vec.x);
   166       double nz = vec.z*xl;
   167       if (std::abs(nz)>0.99)
   168         return loc2pix (nz,phi,sqrt(vec.x*vec.x+vec.y*vec.y)*xl,
true);
   170         return loc2pix (nz,phi,0,
false);
   176     void pix2zphi (I pix, 
double &z, 
double &phi)
 const   180       pix2loc(pix,z,phi,dum_d,dum_b);
   189       pix2loc (pix,z,phi,sth,have_sth);
   190       return have_sth ? pointing(atan2(sth,z),phi) : pointing(acos(z),phi);
   197       pix2loc (pix,z,phi,sth,have_sth);
   199         return vec3(sth*cos(phi),sth*sin(phi),z);
   203         res.set_z_phi (z, phi);
   213       planck_assert(
nside_*ratio==b.
nside_,
"bad nside ratio");
   215       b.pix2xyf(pix, x, y, f);
   217       return xyf2pix(x, y, f);
   220     template<
typename I2> 
void query_disc_internal (pointing ptg, 
double radius,
   221       int fact, rangeset<I2> &pixset) 
const;
   230     void query_disc (pointing ptg, 
double radius, rangeset<I> &pixset) 
const;
   278       std::vector<I> &listpix)
 const   282       pixset.toVector(listpix);
   286       std::vector<I> &listpix, 
int fact=1)
 const   290       pixset.toVector(listpix);
   293     template<
typename I2> 
void query_polygon_internal
   294       (
const std::vector<pointing> &vertex, 
int fact,
   295       rangeset<I2> &pixset) 
const;
   304       rangeset<I> &pixset) 
const;
   329       rangeset<I> &pixset, 
int fact=1) 
const;
   358     void query_strip (
double theta1, 
double theta2, 
bool inclusive,
   359       rangeset<I> &pixset) 
const;
   370     rangeset<I> 
query_strip (
double theta1, 
double theta2, 
bool inclusive)
 const   387       double &costheta, 
double &sintheta, 
bool &shifted) 
const;
   397       double &theta, 
bool &shifted) 
const;
   406         bool &shifted) 
const;
   415     void neighbors (I pix, fix_arr<I,8> &result) 
const;
   421     void get_interpol (
const pointing &ptg, fix_arr<I,4> &pix,
   422                        fix_arr<double,4> &wgt) 
const;
   429     I 
Npix()
 const { 
return npix_; }
   455     void boundaries (I pix, tsize step, std::vector<vec3> &out) 
const;
   457     arr<int> swap_cycles() 
const;
 I nest2peano(I pix) const
T_Healpix_Base< int > Healpix_Base
vec3 pix2vec(I pix) const
rangeset< I > query_disc(pointing ptg, double radius) const
I ang2pix(const pointing &ang) const
void query_disc(pointing ptg, double radius, rangeset< I > &pixset) const
void query_disc(const pointing &dir, double radius, std::vector< I > &listpix) const
void get_ring_info2(I ring, I &startpix, I &ringpix, double &theta, bool &shifted) const
I vec2pix(const vec3 &vec) const
void query_disc_inclusive(const pointing &dir, double radius, std::vector< I > &listpix, int fact=1) const
void query_polygon_inclusive(const std::vector< pointing > &vertex, rangeset< I > &pixset, int fact=1) const
T_Healpix_Base< int64 > Healpix_Base2
void query_polygon(const std::vector< pointing > &vertex, rangeset< I > &pixset) const
I zphi2pix(double z, double phi) const
rangeset< I > query_polygon_inclusive(const std::vector< pointing > &vertex, int fact=1) const
static int nside2order(I nside)
void get_interpol(const pointing &ptg, fix_arr< I, 4 > &pix, fix_arr< double, 4 > &wgt) const
Healpix_Ordering_Scheme Scheme() const
T_Healpix_Base(I nside, Healpix_Ordering_Scheme scheme, const nside_dummy)
void SetNside(I nside, Healpix_Ordering_Scheme scheme)
void swap(T_Healpix_Base &other)
void Set(int order, Healpix_Ordering_Scheme scheme)
void query_strip(double theta1, double theta2, bool inclusive, rangeset< I > &pixset) const
void pix2zphi(I pix, double &z, double &phi) const
void boundaries(I pix, tsize step, std::vector< vec3 > &out) const
static I npix2nside(I npix)
void get_ring_info(I ring, I &startpix, I &ringpix, double &costheta, double &sintheta, bool &shifted) const
I pixel_import(I pix, const T_Healpix_Base &b) const
bool conformable(const T_Healpix_Base &other) const
rangeset< I > query_strip(double theta1, double theta2, bool inclusive) const
double max_pixrad() const
pointing pix2ang(I pix) const
I ring_above(double z) const
void query_disc_inclusive(pointing ptg, double radius, rangeset< I > &pixset, int fact=1) const
void get_ring_info_small(I ring, I &startpix, I &ringpix, bool &shifted) const
void neighbors(I pix, fix_arr< I, 8 > &result) const
rangeset< I > query_disc_inclusive(pointing ptg, double radius, int fact=1) const
I peano2nest(I pix) const
rangeset< I > query_polygon(const std::vector< pointing > &vertex) const
double ring2z(I ring) const
T_Healpix_Base(int order, Healpix_Ordering_Scheme scheme)
Healpix_Ordering_Scheme scheme_