USML
boundary_grid_fast.h
1 
6 #ifndef USML_OCEAN_BOUNDARY_GRID_FAST_H
7 #define USML_OCEAN_BOUNDARY_GRID_FAST_H
8 
9 #include <usml/ocean/boundary_model.h>
10 #include <usml/ocean/reflect_loss_rayleigh.h>
11 
12 namespace usml {
13 namespace ocean {
14 
30 
31 public:
32 
33  //**************************************************
34  // height model
35 
52  this->_height->edge_limit(0, true);
53  this->_height->edge_limit(1, true);
54  if (_reflect_loss_model == NULL) {
57  }
58  }
59 
63  virtual ~boundary_grid_fast() {
64  delete _height;
65  }
66 
76  virtual void height(const wposition& location, matrix<double>* rho,
77  wvector* normal = NULL, bool quick_interp = false) {
78  if (quick_interp) {
81  } else {
84  }
85  if (normal) {
86  matrix<double> gtheta(location.size1(), location.size2());
87  matrix<double> gphi(location.size1(), location.size2());
88  matrix<double> t(location.size1(), location.size2());
89  matrix<double> p(location.size1(), location.size2());
90  this->_height->interpolate(location.theta(), location.phi(), rho,
91  &gtheta, &gphi);
92 
93  t = element_div(gtheta, *rho); // slope = tan(angle)
94  p = element_div(gphi, element_prod(*rho, sin(location.theta())));
95  normal->theta( // normal = -sin(angle)
96  element_div(-t, sqrt(1.0 + abs2(t))));
97  normal->phi(element_div(-p, sqrt(1.0 + abs2(p))));
98  normal->rho(sqrt( // r=sqrt(1-t^2-p^2)
99  1.0 - abs2(normal->theta()) - abs2(normal->phi())));
100  } else {
101  this->_height->interpolate(location.theta(), location.phi(), rho);
102  }
103  }
104 
114  virtual void height(const wposition1& location, double* rho,
115  wvector1* normal = NULL, bool quick_interp = false) {
116  if (quick_interp) {
119  } else {
122  }
123  if (normal) {
124  double loc[2] = { location.theta(), location.phi() };
125  double grad[2];
126  *rho = this->_height->interpolate(loc, grad);
127  const double t = grad[0] / (*rho); // slope = tan(angle)
128  const double p = grad[1] / ((*rho) * sin(location.theta()));
129  normal->theta(-t / sqrt(1.0 + t * t)); // normal = -sin(angle)
130  normal->phi(-p / sqrt(1.0 + p * p));
131  const double N = normal->theta() * normal->theta()
132  + normal->phi() * normal->phi();
133  normal->rho(sqrt(1.0 - N)); // r=sqrt(1-t^2-p^2)
134  } else {
135  double loc[2] = { location.theta(), location.phi() };
136  *rho = this->_height->interpolate(loc);
137  }
138  }
139 
140 protected:
141 
144 
145 }; // end class boundary_grid_fast
146 
147 } // end of namespace ocean
148 } // end of namespace usml
149 
150 #endif
151 
unsigned size2() const
Number of columns in each coordinate.
Definition: wvector.h:264
Definition: reflect_loss_rayleigh.h:96
enum GRID_INTERP_TYPE interp_type(int unsigned dimension) const
Retrieve the type of interpolation for one of the axes.
Definition: data_grid.h:135
World location in geodetic earth coordinates (latitude, longitude, and altitude). ...
Definition: wposition.h:39
virtual void height(const wposition &location, matrix< double > *rho, wvector *normal=NULL, bool quick_interp=false)
Compute the height of the boundary and it's surface normal at a series of locations.
Definition: boundary_grid_fast.h:76
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_abs2< typename E::value_type > >::result_type abs2(const matrix_expression< E > &e)
Magnitude squared of a complex matrix.
Definition: matrix_math.h:270
unsigned size1() const
Number of rows in each coordinate.
Definition: wvector.h:256
virtual void height(const wposition1 &location, double *rho, wvector1 *normal=NULL, bool quick_interp=false)
Compute the height of the boundary and it's surface normal at a single location.
Definition: boundary_grid_fast.h:114
Definition: data_grid.h:23
Bottom model constructed from 2-D data_grid_bathy.
Definition: boundary_grid_fast.h:29
A reflection loss model computes the changes in amplitude and phase that result from the reflection o...
Definition: reflect_loss_model.h:30
Implements fast calculations for data_grids using a non-recursive engine on interpolation.
Definition: data_grid_bathy.h:38
data_grid_bathy * _height
Boundary for all locations.
Definition: boundary_grid_fast.h:143
Individual world vector in spherical earth coordinates.
Definition: wvector1.h:27
double theta() const
Retrieves the colatitude component of the spherical earth coordinate system.
Definition: wvector1.h:91
reflect_loss_model * _reflect_loss_model
Reference to the reflection loss model.
Definition: boundary_model.h:95
double phi() const
Retrieves the longitude component of the spherical earth coordinate system.
Definition: wvector1.h:122
boundary_grid_fast(data_grid_bathy *height, reflect_loss_model *reflect_loss=NULL)
Constructor - Initialize depth and reflection loss components for a boundary.
Definition: boundary_grid_fast.h:47
void reflect_loss(reflect_loss_model *reflect_loss)
Define a new reflection loss model.
Definition: boundary_model.h:104
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
bool edge_limit(int unsigned dimension) const
Returns the edge_limit flag for the requested dimension.
Definition: data_grid.h:174
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_sin< typename E::value_type > >::result_type sin(const matrix_expression< E > &e)
Sine of a matrix.
Definition: matrix_math.h:354
virtual ~boundary_grid_fast()
Destructor - Delete boundary grid.
Definition: boundary_grid_fast.h:63
World location in geodetic earth coordinates (latitude, longitude, and altitude). ...
Definition: wposition1.h:23
double interpolate(double *location, double *derivative=NULL)
Overrides the interpolate function within data_grid using the non-recursive formula.
Definition: data_grid_bathy.h:272
Models plane wave reflection loss from a flat fluid-solid interface.
Definition: reflect_loss_rayleigh.h:86
Definition: data_grid.h:24
World vector in spherical earth coordinates.
Definition: wvector.h:42
A "boundary model" computes the environmental parameters of the ocean's surface or bottom...
Definition: boundary_model.h:58
BOOST_UBLAS_INLINE matrix_unary1_traits< E, scalar_sqrt< typename E::value_type > >::result_type sqrt(const matrix_expression< E > &e)
Square root of a matrix.
Definition: matrix_math.h:296