USML
wvector.h
1 
5 #ifndef USML_TYPES_WVECTOR_H
6 #define USML_TYPES_WVECTOR_H
7 
8 #include <usml/ublas/ublas.h>
9 
10 namespace usml {
11 namespace types {
12 
13 using namespace usml::ublas;
14 
15 class wvector1; // forward reference
16 class wposition1; // forward reference
17 
20 
42 class USML_DECLSPEC wvector
43 {
44 
45 public:
46 
47  //*********************************
48  // initialization
49 
56  wvector(unsigned rows = 1, unsigned cols = 1);
57 
58  //*********************************
59  // Rho property (includes both matrix and indexed accessors)
60 
61 private:
62 
64  matrix<double> _rho;
65 
66 public:
67 
76  inline const matrix<double>& rho() const
77  {
78  return _rho;
79  }
80 
87  template<class E> inline
88  void rho(const matrix_expression<E>& r, bool no_alias = true)
89  {
90  if (no_alias) {
91  noalias(_rho) = r;
92  } else {
93  _rho = r;
94  }
95  }
96 
104  inline double rho(unsigned row, unsigned col) const
105  {
106  return _rho(row, col);
107  }
108 
117  inline void rho(unsigned row, unsigned col, double r)
118  {
119  _rho(row, col) = r;
120  }
121 
122  //*********************************
123  // Theta property (includes both matrix and indexed accessors)
124 
125 private:
126 
128  matrix<double> _theta;
129 
130 public:
131 
140  inline const matrix<double>& theta() const
141  {
142  return _theta;
143  }
144 
151  template<class E> inline
152  void theta(const matrix_expression<E>& t, bool no_alias = true)
153  {
154  if (no_alias) {
155  noalias(_theta) = t;
156  } else {
157  _theta = t;
158  }
159  }
160 
168  inline double theta(unsigned row, unsigned col) const
169  {
170  return _theta(row, col);
171  }
172 
182  inline void theta(unsigned row, unsigned col, double t)
183  {
184  _theta(row, col) = t;
185  }
186 
187  //*********************************
188  // Phi property (includes both matrix and indexed accessors)
189 
190 private:
191 
193  matrix<double> _phi;
194 
195 public:
196 
204  inline const matrix<double>& phi() const
205  {
206  return _phi;
207  }
208 
215  template<class E> inline
216  void phi(const matrix_expression<E>& p, bool no_alias = true)
217  {
218  if (no_alias) {
219  noalias(_phi) = p;
220  } else {
221  _phi = p;
222  }
223  }
224 
232  inline double phi(unsigned row, unsigned col) const
233  {
234  return _phi(row, col);
235  }
236 
245  inline void phi(unsigned row, unsigned col, double p)
246  {
247  _phi(row, col) = p;
248  }
249 
250  //*********************************
251  // utilities
252 
256  inline unsigned size1() const
257  {
258  return _rho.size1();
259  }
260 
264  inline unsigned size2() const
265  {
266  return _rho.size2();
267  }
268 
272  inline void clear()
273  {
274  _rho.clear();
275  _theta.clear();
276  _phi.clear();
277  }
278 
303  void dot(const wvector1& other, matrix<double>& result) const;
304 
317  void dotnorm(const wvector1& other, matrix<double>& result) const;
318 
331  void distance(const wvector1& origin, matrix<double>& result) const;
332 
345  void distance2(const wvector1& origin, matrix<double>& result) const;
346 
347 };
348 
350 } // end of ocean namespace
351 } // end of usml namespace
352 
353 #endif
unsigned size2() const
Number of columns in each coordinate.
Definition: wvector.h:264
const matrix< double > & rho() const
Retrieves the radial component of the spherical earth coordinate system.
Definition: wvector.h:76
void rho(const matrix_expression< E > &r, bool no_alias=true)
Defines the radial component of the spherical earth coordinate.
Definition: wvector.h:88
void theta(unsigned row, unsigned col, double t)
Indexed version for single colatitude component definition.
Definition: wvector.h:182
void phi(const matrix_expression< E > &p, bool no_alias=true)
Defines the longitude component of the spherical earth coordinate.
Definition: wvector.h:216
void theta(const matrix_expression< E > &t, bool no_alias=true)
Defines the colatitude component of the spherical earth coordinate.
Definition: wvector.h:152
unsigned size1() const
Number of rows in each coordinate.
Definition: wvector.h:256
matrix< double > _theta
Storage for the colatitude component of the coordinate system.
Definition: wvector.h:128
void clear()
Reset all data elements back to zero.
Definition: wvector.h:272
matrix< double > _rho
Storage for the radial component of the coordinate system.
Definition: wvector.h:64
Individual world vector in spherical earth coordinates.
Definition: wvector1.h:27
matrix< double > _phi
Storage for the longitude component of the coordinate system.
Definition: wvector.h:193
void phi(unsigned row, unsigned col, double p)
Indexed version for single longitude component definition.
Definition: wvector.h:245
const matrix< double > & phi() const
Retrieves the longitude component of the spherical earth coordinate system.
Definition: wvector.h:204
const matrix< double > & theta() const
Retrieves the colatitude component of the spherical earth coordinate system.
Definition: wvector.h:140
double theta(unsigned row, unsigned col) const
Indexed version for single colatitude component retrieval.
Definition: wvector.h:168
double phi(unsigned row, unsigned col) const
Indexed version for single longitude component retrieval.
Definition: wvector.h:232
double rho(unsigned row, unsigned col) const
Indexed version for single radial component retrieval.
Definition: wvector.h:104
World vector in spherical earth coordinates.
Definition: wvector.h:42
void rho(unsigned row, unsigned col, double r)
Indexed version for single radial component definition.
Definition: wvector.h:117