USML
wvector Class Reference

Detailed Description

World vector in spherical earth coordinates.

Each of the three coordinate parameters (rho, theta, phi) is a 2-D matrix so that the WaveQ3D model can perform ray tracing operations using fast uBLAS operations across the entire wavefront.

Two different coordinate systems use this class as their underlying type:

- The spherical earth coordinate system measures absolute values of 
  rho, theta, phi relative to a fixed geocentric reference system.

- The ray direction coordinate system measures values relative 
  the local basis vectors for rho, theta, phi.  These basis vectors
  change based on the current location of the ray.
References:
Wikipedia Article on "Geodetic System" http://en.wikipedia.org/wiki/Geodetic_system
References:
Portland State Aerospace Society, "Local Tangent Plane", Version 2.01 (2007.9.15), http://www.psas.pdx.edu.

Constructor & Destructor Documentation

wvector ( unsigned  rows = 1,
unsigned  cols = 1 
)

Constructs a new coordinate from matrix dimensions.

Parameters
rowsNumber of rows
colsNumber of columns

Member Function Documentation

void clear ( )
inline

Reset all data elements back to zero.

void distance ( const wvector1 origin,
matrix< double > &  result 
) const

Compute the straight line distance between this point and some other point in space.

Compute the square of the straight line distance between this point and some other point in space.

The distance is related to the dot product by the equation:

     distance = sqrt( r1*r1 + r2*r2 - 2 dot(r1,r2) )

This as the general form of Pythagoras' theorem.

Parameters
originPoint from which distance is measured.
resultDistance from this point to the origin point.
void distance2 ( const wvector1 origin,
matrix< double > &  result 
) const

Compute the square of the straight line distance between this point and some other point in space.

The square of the distance is related to the dot product by the equation:

     distance^2 = r1*r1 + r2*r2 - 2 dot(r1,r2)

This as the general form of Pythagoras' theorem.

Parameters
originPoint from which distance is measured.
resultDistance from this point to the origin point.
void dot ( const wvector1 other,
matrix< double > &  result 
) const

Compute the dot product between this vector and some other spherical earth vector.

The transformation from cartesian to spherical earth coordinate shows that:

     dot product 
         = x1*x2 + y1*y2 + z1*z2
         = r1*r2 * ( cos(t1)cos(t2) + sin(t1)sin(t2)cos(p1-p2) )

This implementation uses the haversine formula to avoid errors in the dot product when distances are small.

     dot product = r1*r2
         * { 1-2*{ sin^2[(t1-t2)/2] + sin(t1)sin(t2)sin^2[(p1-p2)/2] } }
Parameters
otherSecond vector in the dot product.
resultDot product between these two vectors.
References:

Weisstein, Eric W. "Spherical Trigonometry." From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/SphericalTrigonometry.html.

E. Williams, "Aviation Formulary V1.46", http://williams.best.vwh.net/avform.htm

void dotnorm ( const wvector1 other,
matrix< double > &  result 
) const

Dot product divided by the magnitude of the two vectors.

Used to compute the angle between vectors. Uses the haversine formula to avoid errors for short distances.

     cos(angle) = dot(v1,v2) / ( |v1| |v2| )
                = ( cos(t1)cos(t2) + sin(t1)sin(t2)cos(p1-p2) )
                = { 1-2*( sin^2[(t1-t2)/2] + sin(t1)sin(t2)sin^2[(p1-p2)/2] ) }
Parameters
otherSecond vector in the dot product.
resultNormalized dot product between these two vectors.
const matrix<double>& phi ( ) const
inline

Retrieves the longitude component of the spherical earth coordinate system.

Measured as the angle east from the prime meridian.

Returns
Longitude coordinate in radians.
void phi ( const matrix_expression< E > &  p,
bool  no_alias = true 
)
inline

Defines the longitude component of the spherical earth coordinate.

Parameters
pLongitude coordinate in radians.
no_aliasUse uBLAS noalias() assignment speed-up if true.
double phi ( unsigned  row,
unsigned  col 
) const
inline

Indexed version for single longitude component retrieval.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
Returns
Longitude coordinate in radians.
void phi ( unsigned  row,
unsigned  col,
double  p 
)
inline

Indexed version for single longitude component definition.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
pLongitude coordinate in radians.
const matrix<double>& rho ( ) const
inline

Retrieves the radial component of the spherical earth coordinate system.

Measured as the distance from the center of curvature for the area of operations. Because the shape of the earth is elliptical, this is not the same as the distance from the center of the earth.

Returns
Radial coordinate in meters.
void rho ( const matrix_expression< E > &  r,
bool  no_alias = true 
)
inline

Defines the radial component of the spherical earth coordinate.

Parameters
rRadial coordinate in meters.
no_aliasUse uBLAS noalias() assignment speed-up if true.
double rho ( unsigned  row,
unsigned  col 
) const
inline

Indexed version for single radial component retrieval.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
Returns
Radial coordinate in meters.
void rho ( unsigned  row,
unsigned  col,
double  r 
)
inline

Indexed version for single radial component definition.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
rRadial coordinate in meters.
unsigned size1 ( ) const
inline

Number of rows in each coordinate.

unsigned size2 ( ) const
inline

Number of columns in each coordinate.

const matrix<double>& theta ( ) const
inline

Retrieves the colatitude component of the spherical earth coordinate system.

Measured as the angle down from the north pole. This property is the complement of latitude, which is measured up from the equator.

Returns
Colatitude coordinate in radians.
void theta ( const matrix_expression< E > &  t,
bool  no_alias = true 
)
inline

Defines the colatitude component of the spherical earth coordinate.

Parameters
tColatitude coordinate in radians.
no_aliasUse uBLAS noalias() assignment speed-up if true.
double theta ( unsigned  row,
unsigned  col 
) const
inline

Indexed version for single colatitude component retrieval.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
Returns
Colatitude coordinate in radians.
void theta ( unsigned  row,
unsigned  col,
double  t 
)
inline

Indexed version for single colatitude component definition.

Caches the sine of the colatitude as a side effect.

Parameters
rowRow index of the element to access.
colColumn index of the element to access.
tColatitude coordinate in radians.

Member Data Documentation

matrix<double> _phi
private

Storage for the longitude component of the coordinate system.

matrix<double> _rho
private

Storage for the radial component of the coordinate system.

matrix<double> _theta
private

Storage for the colatitude component of the coordinate system.