wposition.h

00001 
00005 #pragma once
00006 
00007 #include <usml/ublas/ublas.h>
00008 #include <usml/types/wvector.h>
00009 
00010 namespace usml {
00011 namespace types {
00014 
00038 class USML_DECLSPEC wposition: public wvector
00039 {
00040 
00041 public:
00042 
00053     wposition(size_t rows = 1, size_t cols = 1, double latitude = 0.0,
00054             double longitude = 0.0, double altitude = 0.0);
00055 
00062     wposition(const wvector & other) :
00063         wvector(other)
00064     {
00065     }
00066 
00077     template<class E1, class E2> inline wposition(
00078             const vector_expression<E1>& latitude,
00079             const vector_expression<E2>& longitude, double altitude = 0.0) :
00080         wvector(latitude().size(), longitude().size())
00081     {
00082         for (int n = 0; n < latitude().size(); ++n) {
00083             for (int m = 0; m < longitude().size(); ++m) {
00084                 this->latitude(n, m, latitude()(n));
00085                 this->longitude(n, m, longitude()(m));
00086                 this->altitude(n, m, altitude);
00087             }
00088         }
00089     }
00090 
00091     //******************************
00092     // Earth Radius static property
00093 
00100     static double earth_radius;
00101 
00124     static void compute_earth_radius(double latitude);
00125 
00126     // ******************************
00127     // Altitude property (includes both matrix and indexed accessors)
00128 
00137     inline matrix<double> altitude() const
00138     {
00139         return rho() - earth_radius;
00140     }
00141 
00149     template<class E> inline
00150     void altitude(const matrix_expression<E>& altitude, bool no_alias = true)
00151     {
00152         rho(altitude + earth_radius, no_alias);
00153     }
00154 
00163     inline double altitude(size_t row, size_t col) const
00164     {
00165         return rho(row, col) - earth_radius;
00166     }
00167 
00176     inline void altitude(size_t row, size_t col, double altitude)
00177     {
00178         rho(row, col, altitude + earth_radius);
00179     }
00180 
00181     //******************************
00182     // Latitude property (includes both matrix and indexed accessors)
00183 
00192     inline matrix<double> latitude() const
00193     {
00194         return to_latitude(theta());
00195     }
00196 
00204     template<class E> inline
00205     void latitude(const matrix_expression<E>& latitude, bool no_alias = true)
00206     {
00207         theta(to_colatitude(latitude), no_alias);
00208     }
00209 
00218     inline double latitude(size_t row, size_t col) const
00219     {
00220         return to_latitude(theta(row, col));
00221     }
00222 
00231     inline void latitude(size_t row, size_t col, double latitude)
00232     {
00233         theta(row, col, to_colatitude(latitude));
00234     }
00235 
00236     // ******************************
00237     // Longitude property (includes both matrix and indexed accessors)
00238 
00247     inline matrix<double> longitude() const
00248     {
00249         return to_degrees(phi());
00250     }
00251 
00259     template<class E> inline
00260     void longitude(const matrix_expression<E>& longitude, bool no_alias = true)
00261     {
00262         phi(to_radians(longitude), no_alias);
00263     }
00264 
00273     inline double longitude(size_t row, size_t col) const
00274     {
00275         return to_degrees(phi(row, col));
00276     }
00277 
00286     inline void longitude(size_t row, size_t col, double longitude)
00287     {
00288         phi(row, col, to_radians(longitude));
00289     }
00290 
00291 };
00292 
00294 } // end of ocean namespace
00295 } // end of usml namespace

Generated on 4 May 2015 for USML by  doxygen 1.6.1