boundary.cpp

Go to the documentation of this file.
00001 /* ============================================================================
00002 'boundary.cpp' defines a boundary class.
00003 
00004 Written by Nicholas Phillips.
00005 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00006 ============================================================================ */
00007 /*
00008                         Fetch header files.
00009 */
00010 #include <math.h>
00011 #include "boundary.h"
00012 #include "map_exception.h"
00013 
00014 using namespace std;
00015 /* ----------------------------------------------------------------------------
00016 'Boundary' is the class constructor.
00017 
00018 Arguments:
00019         None. 
00020 
00021 Returned:
00022         Nothing.
00023 
00024 Written by Nicholas Phillips.
00025 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00026 ---------------------------------------------------------------------------- */
00027 Boundary::Boundary(void)
00028 {
00029         a = b = 0.;
00030         face = 0;
00031         eq = true;
00032         return;
00033 }
00034 /* ----------------------------------------------------------------------------
00035 'set_eq' defines an equatorial boundary.
00036 
00037 Arguments:
00038         z         - 
00039         phi       - 
00040         direction - 
00041 
00042 Returned:
00043         Nothing.
00044 
00045 Written by Nicholas Phillips.
00046 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00047 ---------------------------------------------------------------------------- */
00048 void Boundary::set_eq(const double z, const double phi, const int direction)
00049 {
00050         b = direction*0.375*M_PI;
00051         a = phi - b*z;
00052         eq = true;
00053         return;
00054 }
00055 /* ----------------------------------------------------------------------------
00056 'set_np' defines a north pole boundary.
00057 
00058 Arguments:
00059         z     - 
00060         phi   - 
00061         face_ - 
00062 
00063 Returned:
00064         Nothing.
00065 
00066 Written by Nicholas Phillips.
00067 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00068 ---------------------------------------------------------------------------- */
00069 void Boundary::set_np(const double z, const double phi, const int face_)
00070 {
00071         eq = false;
00072         face = face_;
00073         a = sqrt(1-z)*(0.5*M_PI*(face+1) - phi);
00074         return;
00075 }
00076 /* ----------------------------------------------------------------------------
00077 'set_sp' defines a south pole boundary.
00078 
00079 Arguments:
00080         z     - 
00081         phi   - 
00082         face_ - 
00083 
00084 Returned:
00085         Nothing.
00086 
00087 Written by Nicholas Phillips.
00088 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00089 ---------------------------------------------------------------------------- */
00090 void Boundary::set_sp(const double z, const double phi, const int face_)
00091 {
00092         eq = false;
00093         face = face_;
00094         a = sqrt(1+z)*(phi - 0.5*M_PI*(face-8));
00095         return;
00096 }
00097 /* ----------------------------------------------------------------------------
00098 'operator()' computes phi for a given z.
00099 
00100 Arguments:
00101         z   - 
00102 
00103 Returned:
00104         phi - 
00105 
00106 Written by Nicholas Phillips.
00107 QT4 adaption by Michael R. Greason, ADNET, 27 August 2007
00108 ---------------------------------------------------------------------------- */
00109 double Boundary::operator()(const double z) const
00110 {
00111         double phi;
00112         if( eq )
00113                 phi = a + b*z;
00114         else if( face < 4) {
00115                 phi = 0.5*M_PI*(face+1);
00116                 if( z < 1 )
00117                         phi += -a/sqrt(1-z);
00118         }
00119         else if( face > 7) {
00120                 phi = 0.5*M_PI*(face-8);
00121                 if( z > -1 )
00122                         phi += a/sqrt(1+z);
00123         }
00124         else {
00125                 phi = 0;
00126                 throw MapException(MapException::Other, 0, 
00127                         "Boundary::operator():Bad call");
00128         }
00129         return phi;
00130 }
00131 

Generated on Fri Feb 6 15:32:42 2009 for Skyviewer by  doxygen 1.4.7