Changeset 2973 in Sophya for trunk/SophyaLib/SkyMap/vector3d.cc


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.