| 1 | #include "spherepos.h"
 | 
|---|
| 2 | 
 | 
|---|
| 3 | static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/Samba/spherepos.cc,v 1.2 1999-10-27 10:45:47 ansari Exp $";
 | 
|---|
| 4 | 
 | 
|---|
| 5 | 
 | 
|---|
| 6 | //................. SphereCoordSys class .................
 | 
|---|
| 7 | 
 | 
|---|
| 8 | SphereCoordSys::SphereCoordSys(){
 | 
|---|
| 9 |   id_ = SphereCoordSys_NEUTRAL;
 | 
|---|
| 10 |   description_ = "NEUTRAL SphereCoordSystem";
 | 
|---|
| 11 | }
 | 
|---|
| 12 | 
 | 
|---|
| 13 | SphereCoordSys::SphereCoordSys(int id, const string& description){
 | 
|---|
| 14 |   id_ = id;
 | 
|---|
| 15 |   description_ = description;
 | 
|---|
| 16 | }
 | 
|---|
| 17 | 
 | 
|---|
| 18 | SphereCoordSys::~SphereCoordSys()
 | 
|---|
| 19 | {
 | 
|---|
| 20 | }
 | 
|---|
| 21 | 
 | 
|---|
| 22 | // Temporary implementation of PPersist::
 | 
|---|
| 23 | // To be changed later ($CHECK$  Reza 26/10/99) 
 | 
|---|
| 24 | void SphereCoordSys::ReadSelf(PInPersist& is)
 | 
|---|
| 25 | {
 | 
|---|
| 26 | uint_8 itab[3];
 | 
|---|
| 27 | is.Get(itab, 3);
 | 
|---|
| 28 | id_ = itab[1];
 | 
|---|
| 29 | is.GetStr(description_);
 | 
|---|
| 30 | }
 | 
|---|
| 31 | 
 | 
|---|
| 32 | void SphereCoordSys::WriteSelf(POutPersist& os) const
 | 
|---|
| 33 | {
 | 
|---|
| 34 | //  On ecrit 3 uint_8 
 | 
|---|
| 35 | //  0 : Numero de version,  1 : Id,  2  reserve a l
 | 
|---|
| 36 | uint_8 itab[3];
 | 
|---|
| 37 | itab[0] = 1;
 | 
|---|
| 38 | itab[1] = id_;
 | 
|---|
| 39 | itab[2] = 0;
 | 
|---|
| 40 | os.Put(itab, 3);
 | 
|---|
| 41 | os.PutStr(description_);
 | 
|---|
| 42 | }
 | 
|---|
| 43 | 
 | 
|---|
| 44 | //................. SpherePosition class .................
 | 
|---|
| 45 | 
 | 
|---|
| 46 | SpherePosition::SpherePosition() 
 | 
|---|
| 47 |         : UnitVector()
 | 
|---|
| 48 | {
 | 
|---|
| 49 |   cs_ = new SphereCoordSys;
 | 
|---|
| 50 | }
 | 
|---|
| 51 | 
 | 
|---|
| 52 | SpherePosition::SpherePosition(double theta, double phi, SphereCoordSys* cs)
 | 
|---|
| 53 |         : UnitVector(theta, phi)
 | 
|---|
| 54 | {
 | 
|---|
| 55 | if (cs == NULL) cs_ = new SphereCoordSys;
 | 
|---|
| 56 | else cs_ = cs;
 | 
|---|
| 57 | }
 | 
|---|
| 58 | 
 | 
|---|
| 59 | SpherePosition::SpherePosition(double x, double y, double z, SphereCoordSys* cs)
 | 
|---|
| 60 |         : UnitVector(x, y, z)
 | 
|---|
| 61 | {
 | 
|---|
| 62 | if (cs == NULL) cs_ = new SphereCoordSys;
 | 
|---|
| 63 | else cs_ = cs;
 | 
|---|
| 64 | }
 | 
|---|
| 65 | 
 | 
|---|
| 66 | SpherePosition::~SpherePosition()
 | 
|---|
| 67 | {
 | 
|---|
| 68 | if (cs_) delete cs_;
 | 
|---|
| 69 | }
 | 
|---|
| 70 | 
 | 
|---|
| 71 | UnitVector SpherePosition::Transform(const SphereCoordSys& cs) const
 | 
|---|
| 72 | {
 | 
|---|
| 73 | return(*this);
 | 
|---|
| 74 | }
 | 
|---|
| 75 | 
 | 
|---|
| 76 | double SpherePosition::Separation(const SpherePosition& gamma) const 
 | 
|---|
| 77 | {
 | 
|---|
| 78 | return(this->SepAngle(gamma));
 | 
|---|
| 79 | }
 | 
|---|