Changeset 2973 in Sophya for trunk/SophyaLib/SkyMap


Ignore:
Timestamp:
Jun 20, 2006, 6:01:49 PM (19 years ago)
Author:
ansari
Message:

1/ Nettoyage+commentaires/doxygen ds Vector3d, UnitVector, LongLat,
SphereCoordSys ...
2/ Ajout de la classe angle pour faciliter les conversions rad<>deg<>arcmin
dans le fichier vector3d.h .cc
3/ nettoyage/uniformisation methodes print pour pixelmap, ajout de la
methode PixelMap<T>::Show()
4/ Ajout methodes SphericalMap<T>::HasSymThetaSlice() et
GetSymThetaSliceIndex(int_4 idx) et leurs implementations pour
SphereHEALPix et SphereThetaPhi en vue de l'optimisation du calcul
transforme Ylm
5/ Ajout methode ResolToSizeIndex ds SphereThetaPhi , SphereHEALPix et
SphereECP

Reza , 20 Juin 2006

Location:
trunk/SophyaLib/SkyMap
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/SkyMap/HEALPixUtils.cc

    r2615 r2973  
    687687
    688688 
     689/*!
     690  \brief return the size index value corresponding to resolution \b res 
     691  Computes the size index m providing a resolution better or equal the
     692  specified value \b res (in radian)
     693
     694  - m : size-index
     695  - number of pixels for 4Pi : 12*m*m
     696
     697  \sa SOPHYA::Angle
     698*/
     699int_4 HEALPix::ResolToSizeIndex(double res)
     700{
     701  int_4 m = 1;
     702  double cres = sqrt(M_PI/3.); // 4PI/12
     703  while (cres > 1.001*res) {
     704    m *= 2;
     705    cres = sqrt(4.*M_PI/(12*m*m));
     706  }
     707  return m;
     708
  • trunk/SophyaLib/SkyMap/HEALPixUtils.h

    r1196 r2973  
    2121  static void   pix2ang_ring(int_4 nside,int_4 ipix,double& theta,double& phi) ;
    2222  static void   pix2ang_nest(int_4 nside,int_4 ipix,double& theta,double& phi) ;
     23 
     24  static int_4  ResolToSizeIndex(double res); 
     25  static inline int_4  ResolToNSide(double res)
     26  { return   ResolToSizeIndex(res); }
    2327};
    2428
  • trunk/SophyaLib/SkyMap/longlat.cc

    r2615 r2973  
     1//   Angles/geometrie 3D
     2//        B. Revenu 2000
     3//        R. Ansari 2006
     4// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
     5
    16#include "sopnamsp.h"
    27#include "longlat.h"
    3 //++
    4 // Class        LongLat
    5 //
    6 // include      longlat.h
    7 //
    8 //    translation from  coordinates (longitude, latitude)
    9 //    to theta,phi
    10 //
    11 //    longitude=phi
    12 //
    13 //    latitude=Pi/2-theta
    14 //
    15 //--
    16 //++
    17 // Titre        Constructors
    18 //--
    19 //++
     8
     9
     10/*!
     11   \class SOPHYA::LongLat
     12   \ingroup SkyMap
     13   \brief Coordinate transform from  (longitude,latitude) to (theta,phi)
     14   All angles are specified in radians
     15   
     16   - longitude=phi
     17   - latitude=Pi/2-theta  (latitude=0 -> equator)
     18*/
     19
     20//! Default constructor: longitude=latitude=0
    2021LongLat::LongLat()
    21 //
    22 //--
    2322{
    2423  _lon=0.;
    2524  _lat=0.;
    2625}
    27 //++
     26//! Constructor
    2827LongLat::LongLat(double longitude, double latitude)
    29 //
    30 //--
    3128{
    3229  _lon=mod(longitude,pi2);
     
    3431  else _lat=mod(latitude+pi_over_2,M_PI)-pi_over_2; // dans [-Pi/2,Pi/2]
    3532}
    36 //++
     33
     34//! Constructor form cartesian coordiantes
    3735LongLat::LongLat(double x, double y, double z)
    38 //
    39 //--
    4036{
    4137  double norm=sqrt(x*x+y*y+z*z);
  • trunk/SophyaLib/SkyMap/longlat.h

    r2322 r2973  
    1 //   Geometry handling class
    2 //       B. Revenu, R. Ansari , G. Le Meur   2000
     1//   Angles/geometrie 3D
     2//        B. Revenu 2000
     3//        R. Ansari 2006
    34// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
    45
     
    1011#include <iostream>
    1112#include <stdio.h>
     13
     14
    1215#include <string.h>
    1316#include "utilgeom.h"
     
    3033  LongLat(double x, double y, double z);
    3134  LongLat(const LongLat&);
    32  
     35
     36  //! Set the longitude/latitude coordinates (in radians) 
    3337  void Set(double longitude, double latitude);
     38  //! Return the longitude value (in radians)
    3439  double Longitude() const {return _lon;}
     40  //! Return the phi value (in radians)
    3541  double Phi() const {return _lon;}
     42  //! Return the latitude value (in radians)
    3643  double Latitude() const {return _lat;}
     44  //! Return the theta value (in radians)
    3745  double Theta() const {return pi_over_2-_lat;}
    3846
     47  //! print the object (ascii representation) on stream os
    3948  void Print(ostream& os) const;
    4049 
  • trunk/SophyaLib/SkyMap/pixelmap.h

    r2322 r2973  
    66#include "dvlist.h"
    77#include "spherepos.h"
     8#include "datatype.h"
    89#include <iostream>
     10#include <typeinfo>
    911
    1012namespace SOPHYA {
     
    100102inline PixelMap<T>& operator = (T v) { return(SetT(v)); }
    101103
     104//! Ascii print of synthetic information about the pixelmap on stream os
     105virtual void  Show(ostream& os) const;
     106//! Show information on \b cout
     107inline  void  Show() const { Show(cout); }
    102108
    103109                     
    104 //++
     110//! Return a reference to the associated DVList object
    105111DVList& Info()
    106 //
    107 // Renvoie une reference sur l''objet DVList Associe
    108 //--
    109112  {
    110113    if (mInfo_ == NULL)  mInfo_ = new DVList;
     
    122125};
    123126
     127template <class T>
     128inline ostream& operator << (ostream& s,  const PixelMap<T> & a)
     129{ a.Show(s);   return(s); }
    124130
    125131template <class T>
     
    151157}
    152158
     159template <class T>
     160void PixelMap<T>::Show(ostream& os) const
     161{
     162os << "PixelMap<T>::Show() class: " << typeid(*this).name()
     163   << " T= " << DataTypeInfo<T>::getTypeName() << endl;
     164double solang = 0.;
     165if (NbPixels() > 0) solang = PixSolAngle(NbPixels()/2);
     166 double frac = NbPixels()*solang*100/(4.*M_PI);
     167if (frac > 100.) frac = 100.;
     168os << " NbPixels()= " << NbPixels() << " ResolArcMin ~="
     169   << Angle(sqrt(solang)).ToArcMin() << " SphereFrac ~= "
     170   << frac << " % of 4Pi" << endl;
     171}
     172
    153173
    154174} // Fin du namespace
  • trunk/SophyaLib/SkyMap/sphereecp.cc

    r2968 r2973  
    373373
    374374template <class T>
    375 void  SphereECP<T>::Print(ostream& os) const
    376 {
     375void  SphereECP<T>::Show(ostream& os) const
     376{
     377  PixelMap<T>::Show(os);
    377378  if (_partial)
    378379    os << "SphereECP<T>::Print() - Partial ECP Map NPhi=" << _pixels.SizeX()
     
    383384    os << "SphereECP<T>::Print() - Full ECP Map NPhi=" << _pixels.SizeX()
    384385       << " x NTheta= " <<  _pixels.SizeY() << " SolidAngle=" << PixSolAngle() << endl;
     386}
     387
     388template <class T>
     389void  SphereECP<T>::Print(ostream& os) const
     390{
     391  Show(os);
    385392  os << _pixels;
    386393}
  • trunk/SophyaLib/SkyMap/sphereecp.h

    r2968 r2973  
    2222{
    2323public :
     24
     25//! return the size index value corresponding to resolution res (in radian)
     26static inline int_4 ResolToSizeIndex(double res)
     27  { return (M_PI/res); }
     28
    2429  // Constructeur par defaut
    2530                        SphereECP();
     
    107112
    108113  // Impression
     114  virtual void          Show(ostream& os) const;
    109115  virtual void          Print(ostream& os) const;
    110116  inline void           print(ostream& os) const { Print(os); }
     117  inline void           Print() const { Print(cout); }
    111118
    112119  // ---- les operations =, +, - , *
     
    143150};
    144151
    145 template <class T>
    146 inline ostream& operator << (ostream& os, const SphereECP<T>& a)
    147   { a.Print(os);    return(os);  }
    148152
    149153}// Fin du namespace
  • trunk/SophyaLib/SkyMap/spherehealpix.cc

    r2968 r2973  
    311311}
    312312
     313//! Return true : All theta slices have a symmetric slice at Pi-Theta in SphereHEALPix
     314template <class T>
     315bool SphereHEALPix<T>::HasSymThetaSlice() const
     316{
     317  return true;
     318}
     319//! Return the slice index for the symmetric slice at theta=Pi-ThetaOfSlice(idx)
     320template <class T>
     321int_4 SphereHEALPix<T>::GetSymThetaSliceIndex(int_4 idx) const
     322{
     323  if(idx < 0 || idx >= NbThetaSlices())
     324    throw RangeCheckError("SphereHEALPix::GetSymThetaSliceIndex index out of range");
     325  return (NbThetaSlices()-1-idx);
     326}
     327
    313328/*!  \fn void SOPHYA::SphereHEALPix::GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const
    314329
     
    675690void SphereHEALPix<T>::print(ostream& os) const
    676691{
     692  Show(os);
    677693  if(this->mInfo_) os << "  DVList Info= " << *(this->mInfo_) << endl;
    678694  //
  • trunk/SophyaLib/SkyMap/spherehealpix.h

    r2968 r2973  
    4444         { HEALPix::pix2ang_nest(nside, ipix, theta, phi); }
    4545
     46  //! return the size index (=nside) corresponding to resolution res (in radian)
     47  static inline int_4 ResolToSizeIndex(double res)
     48         { return  HEALPix::ResolToSizeIndex(res); }
     49
     50  //! return the size index (=nside) corresponding to resolution res (in radian)
     51  static inline int_4 ResolToNSide(double res)
     52         { return  HEALPix::ResolToSizeIndex(res); }
     53
    4654SphereHEALPix();
    4755SphereHEALPix(int_4 m);
     
    7280virtual uint_4 NbThetaSlices() const;
    7381virtual r_8  ThetaOfSlice(int_4 index) const;
     82virtual bool  HasSymThetaSlice() const;
     83virtual int_4 GetSymThetaSliceIndex(int_4 idx) const;
     84
    7485virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const;
    7586virtual void GetThetaSlice(int_4 sliceIndex,r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const ;
     
    125136
    126137void print(ostream& os) const;
    127 
     138inline void Print(ostream& os) const { print(os); }
    128139
    129140
  • trunk/SophyaLib/SkyMap/spherepos.cc

    r2615 r2973  
     1// Classes SphereCoordSys , SpherePosition
     2//      G. Le Meur  2000
     3//      R. Ansari 2006 (documentation/commentaire)
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16// 04/01/00 : implantation de la persistance par classe deleguee - Guy Le Meur
    27
     
    611#include <typeinfo>
    712
    8 static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.3 2004-09-10 09:54:31 cmv Exp $";
     13static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.4 2006-06-20 16:01:48 ansari Exp $";
    914
    1015
    1116//................. SphereCoordSys class .................
    1217
     18/*!
     19   \class SOPHYA::SphereCoordSys
     20   \ingroup SkyMap
     21   \brief  Class which describes the coordinate system used in spherical maps
     22   Current implementation (~ 2006 ) does NOT perform any coordinate transformation
     23   \sa SOPHYA::PixelMap
     24*/
     25
    1326SphereCoordSys::SphereCoordSys(){
    14   id_ = SphereCoordSys_NEUTRAL;
     27  id_ = SphereCoordSys::NEUTRAL;
    1528  description_ = "NEUTRAL SphereCoordSystem";
    1629}
     
    2134}
    2235
    23 SphereCoordSys::SphereCoordSys(int id, const string& description){
     36SphereCoordSys::SphereCoordSys(int id,
     37                               const string& description){
    2438  id_ = id;
    2539  description_ = description;
     
    112126
    113127//................. SpherePosition class .................
     128/*!
     129   \class SOPHYA::SpherePosition
     130   \ingroup SkyMap
     131   \brief  Class to define a (angular) position on a sphere, combined a coordinate system
     132   Current implementation (~ 2006 ) does NOT perform any coordinate transformation
     133   \sa SOPHYA::PixelMap
     134*/
    114135
    115136SpherePosition::SpherePosition()
  • trunk/SophyaLib/SkyMap/spherepos.h

    r764 r2973  
    99#include "anydataobj.h"
    1010
    11 static char *head_spherepos_h_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.h,v 1.1.1.1 2000-03-02 17:05:39 ansari Exp $";
     11static char *head_spherepos_h_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.h,v 1.2 2006-06-20 16:01:48 ansari Exp $";
    1212
    1313namespace SOPHYA {
    14 
    15 enum SphereCoordSysIds { SphereCoordSys_NEUTRAL =0,
    16                          SphereCoordSys_ROTATION =1,
    17                          SphereCoordSys_OTHER = 0xFFFF
    18 };
    1914
    2015 
     
    2217public:
    2318 
     19  enum SphereCoordSysIds { NEUTRAL =0,
     20                           ROTATION =1,
     21                           OTHER = 0xFFFF
     22  };
     23
    2424  SphereCoordSys();
    2525  SphereCoordSys(const SphereCoordSys& a);
  • trunk/SophyaLib/SkyMap/spherethetaphi.cc

    r2969 r2973  
    603603}
    604604
     605//! Return true : All theta slices have a symmetric slice at Pi-Theta in SphereThetaPhi
     606template <class T>
     607bool SphereThetaPhi<T>::HasSymThetaSlice() const
     608{
     609  return true;
     610}
     611//! Return the slice index for the symmetric slice at theta=Pi-ThetaOfSlice(idx)
     612template <class T>
     613int_4 SphereThetaPhi<T>::GetSymThetaSliceIndex(int_4 idx) const
     614{
     615  if(idx < 0 || idx >= NbThetaSlices())
     616    throw RangeCheckError("SphereThetaPhi::GetSymThetaSliceIndex index out of range");
     617  return (NbThetaSlices()-1-idx);
     618}
     619
    605620/*!   
    606621  \brief return a Theta slice information
     
    676691void SphereThetaPhi<T>::print(ostream& os) const
    677692{
     693  Show(os);
    678694  if(this->mInfo_) os << "  DVList Info= " << *(this->mInfo_) << endl;
    679695  //
  • trunk/SophyaLib/SkyMap/spherethetaphi.h

    r2969 r2973  
    2626
    2727public :
     28
     29//! return the size index value corresponding to resolution res (in radian)
     30static inline int_4 ResolToSizeIndex(double res)
     31  { return (M_PI/2./res); }
    2832
    2933SphereThetaPhi();
     
    120124
    121125virtual r_8  ThetaOfSlice(int_4 index) const;
     126virtual int_4 GetSymThetaSliceIndex(int_4 idx) const;
     127virtual bool  HasSymThetaSlice() const;
     128
    122129virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const;
    123130virtual void GetThetaSlice(int_4 index, r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const ;
    124131
    125132
    126 //! ASCII dump (print) of the pixel map
     133//! ASCII dump (print) of the pixel map on stream \b os
    127134void print(ostream& os) const;
     135//! ASCII dump (print) of the pixel map
     136inline void Print(ostream& os) const { print(os); }
     137//! ASCII dump (print) of the pixel map on cout
     138inline void Print() const { print(cout); }
    128139
    129140
  • trunk/SophyaLib/SkyMap/sphericalmap.h

    r2968 r2973  
    4848virtual uint_4 NbThetaSlices() const=0;
    4949virtual r_8  ThetaOfSlice(int_4 index) const=0;
     50/*!
     51  Return true if some theta slices have a symmetric counter-part at (Pi-Theta)
     52  (the default implementation return true)
     53*/
     54virtual bool  HasSymThetaSlice() const { return false; }
     55/*!
     56  Return the slice index for the symmetric slice theta=Pi-ThetaOfSlice(idx)
     57  an invalid index is returned if the symmetric slice does not exist
     58*/
     59virtual int_4 GetSymThetaSliceIndex(int_4 idx) const { return -1; }
    5060virtual void GetThetaSlice(int_4 index,r_8& theta, TVector<r_8>& phi, TVector<T>& value) const=0;
    5161virtual void GetThetaSlice(int_4 sliceIndex, r_8& theta, r_8& phi0, TVector<int_4>& pixelIndices,TVector<T>& value) const=0 ;
  • trunk/SophyaLib/SkyMap/unitvector.cc

    r2615 r2973  
     1//   3-D Geometry
     2//        B. Revenu, G. Le Meur   2000
     3//        R. Ansari (documentation 2006)
     4// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
     5
    16#include <math.h>
    27#include "sopnamsp.h"
    38#include "unitvector.h"
    4 //*****************************************************************************
    5 //++
    6 // Class        UnitVector
    7 //
    8 // include      unitvector.h vector3d.h math.h
    9 //--
    10 //++
    11 //
    12 // Links        Parents
    13 //
    14 //    Vector3d
    15 //   
    16 //--
    17 //++
    18 // Titre        Constructors
    19 //--
    20 //++
     9
     10/*!
     11   \class SOPHYA::UnitVector
     12   \ingroup SkyMap
     13   \brief Specialisation of Vector3d class for representing unit (length=1) 3-vectors.
     14*/
     15
     16//! Default constructor : unit vector in the x direction
    2117UnitVector::UnitVector() : Vector3d(1.,0.,0.)
    22 //
    23 //--
    2418{
    2519}
    26 //++
     20
     21//! Constructor: Unit vector along the x,y,z cartesian coordinates
    2722UnitVector::UnitVector(double x, double y, double z) : Vector3d(x,y,z)
    28 //
    29 //--
    3023{
    3124  this->Normalize();
    3225}
    33 //++
     26
     27//! Constructor: Unit vector along the theta,phi direction (spherical coordinates)
    3428UnitVector::UnitVector(double theta, double phi) : Vector3d(theta,phi)
    35 //
    36 //--
    3729{
    3830  this->Normalize();
    3931}
    40 //++
     32//! copy constructor
    4133UnitVector::UnitVector(const Vector3d& v) : Vector3d(v)
    42 //
    43 //--
    4434{
    4535  this->Normalize();
    4636}
    47 //++
    48 // Titre        Public Method
    49 //--
    50 //++
     37//! print the vector on stream os
    5138void UnitVector::Print(ostream& os) const
    52 //
    53 //--
    5439{
    5540  os << "UnitVector : (X,Y,Z)= (" << _x << ", " << _y << ", " << _z
  • trunk/SophyaLib/SkyMap/vector3d.cc

    r2615 r2973  
     1// Classes Angle Vector3d
     2//      B. Revenu , G. Le Meur  2000
     3//      R. Ansari 2006
     4// LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
     5
    16#include "sopnamsp.h"
    27#include "machdefs.h"
     
    510#include "vector3d.h"
    611#include "utilgeom.h"
    7 //++
    8 // Class        Vector3d
    9 //
    10 // include      vector3d.h utilgeom.h  longlat.h math.h
    11 //
    12 //
    13 //    3-D geometry.
    14 //    All computations are made with angles in radians and with spherical
    15 //    coordinates theta, phi.
    16 //
    17 //    Concerning Euler's angles, the reference is :
    18 //
    19 //    "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
    20 //--
    21 //++
    22 // Titre        Constructors
    23 //--
    24 //++
     12
     13// Class de conversion d'angles R. Ansari , Juin 2006
     14double Angle::_deg2rad = M_PI/180.;
     15double Angle::_rad2deg = 180./M_PI;
     16double Angle::_rad2min = 180./M_PI*60.;
     17double Angle::_rad2sec = 180./M_PI*3600.;
     18
     19/*!
     20   \class SOPHYA::Angle
     21   \ingroup SkyMap
     22   \brief  Class to ease angle conversions (radian <> degree <> arcmin <> arcsec).
     23   The angle value is kept in radians internally.
     24   \code
     25   // Example to convert 0.035 radians to arcsec
     26   double vr = 0.035;
     27   cout << "Angle rad= " << vr << " ->arcsec= " << Angle(vr).ToArcSec() << endl;
     28   // Example to convert 2.3 arcmin to radian - we use the conversion operator
     29   double vam = 2.3;
     30   cout << "Angle arcmin= " << vam << " ->rad= "
     31        << (double)Angle(vam, Angle::ArcMin) << endl;
     32   \endcode
     33
     34*/
     35
     36Angle::Angle(double val, Angle::AngleUnit un)
     37{
     38  switch (un) {
     39  case Angle::Radian :
     40    _angrad = val;
     41    break;
     42  case Angle::Degree :
     43    _angrad = val*_deg2rad;
     44    break;
     45  case Angle::ArcMin :
     46    _angrad = val/_rad2min;
     47    break;
     48  case Angle::ArcSec :
     49    _angrad = val/_rad2sec;
     50    break;
     51  default:
     52    _angrad = val;
     53    break;
     54  }
     55}
     56
     57//   3-D Geometry
     58//        B. Revenu, G. Le Meur   2000
     59// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
     60
     61/*!
     62   \class SOPHYA::Vector3d
     63   \ingroup SkyMap
     64   \brief 3-D geometry.
     65   All computations are made with angles in radians and with spherical
     66   coordinates theta, phi.
     67   Concerning Euler's angles, the reference is :
     68
     69   "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
     70*/
     71
     72//! default constructor - unit vector along x direction
    2573Vector3d::Vector3d()
    26 //
    27 //--
    2874{
    2975  Setxyz(1.,0.,0.);
    3076}
    31 //++
     77
     78//! Constructor with specification of cartesian coordinates
    3279Vector3d::Vector3d(double x, double y, double z)
    33 //
    34 //--
    3580{
    3681  _x=x;
     
    3984  xyz2ThetaPhi();
    4085}
    41 //++
     86//! Constructor: unit vector with direction (spherical coordinates) specification
    4287Vector3d::Vector3d(double theta, double phi)
    43 //
    44 //--
    4588{
    4689 // _theta=mod(theta,M_PI); // dans [0;pi]
     
    5598  ThetaPhi2xyz();
    5699}
    57 //++
     100
     101//! Constructor: unit vector with longitude-latitude specification
    58102Vector3d::Vector3d(const LongLat& ll)
    59 //
    60 //--
    61103{
    62104  _theta=ll.Theta(); // dans [0;pi]
     
    64106  ThetaPhi2xyz();
    65107}
    66 //++
     108
     109//! Copy constructor
    67110Vector3d::Vector3d(const Vector3d& v)
    68 //
    69 //--
    70111{
    71112  _x=v._x;
     
    75116  _phi=v._phi;
    76117}
    77 //++
    78 // Titre        Public methods
    79 //--
    80 //++
    81 void Vector3d::SetThetaPhi(double theta, double phi)
    82 //
    83 //--
     118
     119//! Set/changes the vector direction (result is a unit vector)
     120void Vector3d::SetThetaPhi(double theta, double phi)
    84121{
    85122  _theta=mod(theta,M_PI);
     
    87124  ThetaPhi2xyz();
    88125}
    89 //++
     126
     127//! Set/changes the vector specifying cartesian coordinates
    90128void Vector3d::Setxyz(double x, double y, double z)
    91 //
    92 //--
    93129{
    94130  _x=x;
     
    125161    }
    126162}
    127 //++
     163//! Normalize the vector (-> unit length) for non zero vectors
    128164Vector3d& Vector3d::Normalize()
    129 //
    130 //--
    131165{
    132166  double norm=this->Norm();
    133167  if( norm != 0. )  (*this)/=norm;
    134   else cerr << "Division par zero" << endl;
     168  //DEL  else cerr << "Division par zero" << endl;
    135169  return *this;
    136170}
    137 //++
     171
     172//! Return the vector norm (length)
    138173double Vector3d::Norm() const
    139 //
    140 //--
    141174{
    142175  return sqrt(_x*_x+_y*_y+_z*_z);
    143176}
    144 //++
     177
     178//! Return the scalar (dot) product of the two vectors
    145179double Vector3d::Psc(const Vector3d& v) const
    146 //
    147 //    dot product
    148 //--
    149180{
    150181  return _x*v._x+_y*v._y+_z*v._z;
  • trunk/SophyaLib/SkyMap/vector3d.h

    r2322 r2973  
    11//   3-D Geometry
    22//        B. Revenu, G. Le Meur   2000
     3//        R. Ansari 2006
    34// DAPNIA/SPP (Saclay) / CEA    LAL - IN2P3/CNRS  (Orsay)
    45
     
    1516#include "longlat.h"
    1617
     18
     19namespace SOPHYA {
     20
     21//! Class to ease angle conversions (radian <> degree <> arcmin <> arcsec)
     22class Angle {
     23public:
     24  enum AngleUnit { Radian, Degree, ArcMin, ArcSec };
     25  //! Constructor with specification of angle value in radian
     26  Angle(double val=0.) { _angrad = val; }
     27  //! Constructor with specification of angle value and unit
     28  Angle(double val, Angle::AngleUnit un);
     29  //! Copy constructor
     30  Angle(Angle const& a) { _angrad = a._angrad; }
     31
     32  //! Conversion to radian
     33  inline double ToRadian() const { return _angrad; }
     34  //! Conversion to degree
     35  inline double ToDegree() const { return _angrad*_rad2deg; }
     36  //! Conversion to arcmin
     37  inline double ToArcMin() const { return _angrad*_rad2min; }
     38  //! Conversion to arcsec
     39  inline double ToArcSec() const { return _angrad*_rad2sec; }
     40
     41  //! return the angle value in radian
     42  inline operator double () const { return _angrad; }
     43
     44protected: 
     45  double _angrad;  // angle in radians
     46
     47  static double _deg2rad;  // deg -> radian conversion factor
     48  static double _rad2deg;  // rad -> degree conversion factor
     49  static double _rad2min;  // rad -> arcmin conversion factor
     50  static double _rad2sec;  // rad -> arcmin conversion factor
     51 
     52};
     53
    1754/*
    1855  Geometrie en dimension 3.
     
    2057  et en coordonnees spheriques theta,phi
    2158  pour les rotations (angles d'Euler) ma source est
     59  B. Revenu / G. Le Meur
    2260  "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
    2361*/
    24 /*!    3-D geometry.
    25 
    26     All computations are made with angles in radians and with spherical
    27     coordinates theta, phi.
    28 
    29     Concerning Euler's angles, the reference is :
    30  
    31     "Classical Mechanics" 2nd edition, H. Goldstein, Addison Wesley
    32 */
    33 
    34 namespace SOPHYA {
    3562 
    3663class Vector3d
     
    6592
    6693  // ecart angulaire entre 2 vecteurs dans [0,Pi]
    67   /*!   angular gap between 2 vectors in [0,Pi] */
     94  //!   angular gap between 2 vectors in [0,Pi]
    6895  virtual double SepAngle(const Vector3d&) const;
    6996
    7097  // produit vectoriel
    71   /*!    vector product */
    72   virtual Vector3d Vect(const Vector3d&) const;
     98  //! return the vector product (*this)^v2
     99  virtual Vector3d Vect(const Vector3d& v2) const;
    73100
    74101  // vecteur perpendiculaire de meme phi
    75   /*!    perpendicular vector, with equal phi */
     102  //! return the perpendicular vector, with equal phi
    76103  virtual Vector3d VperpPhi() const;
    77104
    78105  // vecteur perpendiculaire de meme theta
    79   /*!    perpendicular vector with equal theta */
     106  //! return the perpendicular vector, with equal theta
    80107  virtual Vector3d VperpTheta() const;
    81108
     
    84111
    85112  // rotations d'Euler
    86   /*!    Euler's rotations */
    87   // rotations d Euler
     113  //! Perform   Euler's rotations
    88114  virtual Vector3d Euler(double, double, double) const;
    89115
    90116  // rotation inverse
    91   /*!    inverse rotation */
     117  //! perform   inverse Euler rotation
    92118  Vector3d InvEuler(double, double, double) const;
    93119
    94120  // rotation d'angle phi autour d'un axe omega (regle du tire-bouchon)
    95   /*!    rotation of angle phi around an axis omega (Maxwell's rule) */
     121  //! perform rotation of angle phi around an axis omega (Maxwell's rule)
    96122  Vector3d Rotate(const Vector3d& omega,double phi) const;
    97123
     
    148174}
    149175
     176
    150177} // namespace SOPHYA
    151178
Note: See TracChangeset for help on using the changeset viewer.