CARMA C++
sza::util::Coordinates Class Reference

This class performs conversions between several different coordinate systems. More...

#include <carma/szautil/Coordinates.h>

Inherits sza::util::Vector< type >.

Public Types

enum  SrcDist { ACTUAL, INF }
 Enumerate types of distances we might pass to methods. More...
 

Public Member Functions

void add (double up, double east, double north)
 Increment the LLA of this object by the specified UEN offset. More...
 
double & altitude ()
 
 Coordinates ()
 Constructor. More...
 
 Coordinates (Angle longitude, Angle latitude, double altitude)
 Constructor with initialization of LLA. More...
 
 Coordinates (Coordinates &coord)
 Copy constructor. More...
 
Vector< double > getAbsXyz (double east=0.0, double north=0.0, double up=0.0)
 Return absolute XYZ coordinates of the given UEN point, relative to the LLA point of this object. More...
 
Vector< Angle > getAzEl (Angle longitude, Angle latitude, double altitude)
 Given a LLA coordinate, return its Az, El relative to the position of this object. More...
 
Vector< Angle > getAzEl (Coordinates &coords)
 
Vector< double > getLla (double east=0.0, double north=0.0, double up=0.0)
 Return LLA of the passed UEN offset point, relative to the LLA coordinates stored in this object. More...
 
Vector< double > getUen (Angle longitude, Angle latitude, double altitude)
 Return UEN coordinates of the specified LLA point, relative to the coordinates stored in this object. More...
 
Vector< double > getUen (Coordinates &coords)
 
Vector< double > getUvw (HourAngle ha, DecAngle declination)
 Return the UVW coordinates for the current LLA location, of a source at the requested declination and hour angle. More...
 
Vector< double > getXyz (double east=0.0, double north=0.0, double up=0.0, bool geocentric=true)
 Return XYZ coordinates of the given UEN point, relative to the LLA point of this object. More...
 
Angle & latitude ()
 
Angle & longitude ()
 Position return methods. More...
 
void setAltitude (double altitude)
 Set just the altitude. More...
 
void setLatitude (Angle latitude)
 Set just the latitude. More...
 
void setLla (Angle longitude, Angle latitude, double altitude)
 Set methods. More...
 
void setLongitude (Angle longitude)
 Set just the longitude. More...
 
virtual ~Coordinates ()
 Destructor. More...
 
- Public Member Functions inherited from sza::util::Vector< type >
void add (Vector< type > vec)
 
double magnitude ()
 Get the magnitude of a vector. More...
 
const type operator* (const Vector< type > &vec)
 Assignment void operator=(const Vector<type>& vec);. More...
 
const Vector< double > operator* (double factor)
 ...................................................................... More...
 
const Vector< type > operator+ (const Vector< type > &vec)
 Vector addition. More...
 
const Vector< type > operator+ (const type offset)
 ...................................................................... More...
 
const Vector< type > operator- (const Vector< type > &vec)
 ...................................................................... More...
 
const Vector< type > operator- (const type offset)
 ...................................................................... More...
 
const Vector< double > operator/ (const type factor)
 ...................................................................... More...
 
type & operator[] (unsigned i)
 Define an operator for accessing elements of the vector. More...
 
void push_back (type el)
 
void resize (unsigned n)
 Private resize operator. More...
 
unsigned size ()
 Query the size of the vector. More...
 
 Vector (unsigned n)
 Constructor. More...
 
 Vector (type el0, type el1, type el2)
 Constructor. More...
 
 Vector (const Vector< type > &vec)
 Copy constructor. More...
 
 Vector ()
 Private constructor with no arguments. More...
 
virtual ~Vector ()
 Destructor. More...
 

Static Public Member Functions

static Vector< double > absXyzAndUenToLla (double XA, double YA, double ZA, double up=0.0, double east=0.0, double north=0.0)
 Return the LLA of the point given by the specified absolute XYZ and UEN offset. More...
 
static Vector< double > absXyzToLla (double XA, double YA, double ZA)
 Given absolute XYZ, convert to LLA. More...
 
static Vector< double > azElToUen (Angle az, Angle el, double r=1.0)
 Given Azimuth and Elevation, return the UEN coordinates. More...
 
static Vector< double > dHaDdecToXyz (HourAngle dHa, Angle dDec)
 Return the (X, Y, Z) coordinates of the specified (Ha, Dec) coordinate. More...
 
static Vector< double > getd2Uvw (HourAngle ha, DecAngle declination, double X, double Y, double Z)
 Second derivatives of the UVW coordinates wrt time. More...
 
static Vector< double > getdUvw (HourAngle ha, DecAngle declination, double X, double Y, double Z)
 First derivatives of the UVW coordinates wrt time. More...
 
static Delay getGeometricDelay (HourAngle ha, DecAngle declination, double X, double Y, double Z, double X0, double Y0, double Z0, bool doMotionCorrection)
 Get the delay for the Ha and Dec of a source, given XYZ coordinates of a baseline. More...
 
static Delay getGeometricDelay (Angle latitude, Angle az, Angle el, double X, double Y, double Z)
 Calculate the delay, in NanoSeconds, for the specified XYZ point, for a source direction given by az/el. More...
 
static Matrix< double > getThetaRhoToXyzDecRot (Declination &dec)
 
static Matrix< double > getThetaRhoToXyzRhoRot (Angle &rho)
 
static Matrix< double > getThetaRhoToXyzThetaRot (Angle &theta)
 
static Vector< double > haDecAndXyzToUvw (HourAngle ha, DecAngle declination, double X, double Y, double Z)
 Return the UVW coordinates, relative to a given XYZ coordinate, for the requested source position. More...
 
static Vector< double > haDecToXyz (HourAngle ha, DecAngle declination, bool geocentric=true, SrcDist type=INF, double r=0.0)
 Return the XYZ coordinate of a vector at requested (Ha, Dec) direction and of length r. More...
 
static Vector< Angle > laAndHaDecToAzEl (Angle latitude, double altitude, HourAngle ha, DecAngle declination, bool geocentric=true, SrcDist type=INF, double dist=1.0)
 Return the Az El of a source at a given HA and Dec. More...
 
static Vector< double > laAndUenToXyz (Angle latitude, double altitude, double up=0.0, double east=0.0, double north=0.0, bool geocentric=true)
 Return the XYZ coordinates of an UEN point relative to a fiducial LA. More...
 
static Vector< double > llaAndLlaToUen (Angle fiducialLongitude, Angle fiducialLatitude, double fiducialAltitude, Angle longitude, Angle latitude, double altitude)
 Return the UEN of an LLA point relative to a fiducial LLA point. More...
 
static Vector< double > llaAndUenToAbsXyz (Angle longitude, Angle latitude, double altitude, double up, double east, double north, bool doTrans=true)
 Return absolute XYZ of the point offset by UEN from a given LLA point. More...
 
static Vector< double > llaAndUenToLla (Angle longitude, Angle latitude, double altitude, double up, double east, double north)
 Return the LLA of the point given by an UEN offset relative to a fiducial LLA. More...
 
static Vector< double > lngLatAndAzElToLngLat (Angle &lng, Angle &lat, Angle &az, Angle &el)
 Return the LL of the point given by an az/el offset relative to a fiducial LL. More...
 
static void raDecAndThetaRhoToRaDec (HourAngle &ra0, Declination &dec0, Angle &theta, Angle &rho, HourAngle &ra, Declination &dec)
 ...................................................................... More...
 
static Vector< double > thetaRhoToXyz (Declination &dec, Angle &theta, Angle &rho)
 
static Vector< double > topoXYZToUen (double X, double Y, double Z, Angle latitude)
 Given a topocentric XYZ, return the UEN coordinates at a given latitude. More...
 
static Vector< Angle > uenToAzEl (double U, double E, double N)
 Given UEN, return the Azimuth and Elevation. More...
 
static Vector< Angle > uenToAzEl (Vector< double > &uen)
 
static void xyzToDhaDdec (double X, double Y, double Z, HourAngle &dHa, Angle &dDec)
 Return the dHa and dDec corresponding to the specified (X, Y, Z) coordinate. More...
 
static void xyzToDhaDdec (Vector< double > &xyzVals, HourAngle &dHa, Angle &dDec)
 Return the dHa and dDec corresponding to the specified (X, Y, Z) coordinate. More...
 

Static Public Attributes

static const double auToMeters_
 Conversion between AU and meters. More...
 
static const double earthEqRadiusMeters_
 
static const double earthFlattening_
 Flattening of the earth. More...
 
static const double earthRotVelRadPerSec_
 Rotational angular velocity of the earth, in radians per second. More...
 
static const double lightSpeed_
 

Friends

std::ostream & operator<< (std::ostream &os, Coordinates &coords)
 Allows cout << coords. More...
 

Additional Inherited Members

- Protected Attributes inherited from sza::util::Vector< type >
std::vector< type > data_
 

Detailed Description

This class performs conversions between several different coordinate systems.

These are described below.

(L, L, A): The longiude/latitude/altitude coordinate system. I will refer to this in shorthand as LLA, and coordinates as (L, L, A). Longitude increases from 0 at Greenwich, England in an easterly direction, and decreases in a westerly direction. East longitudes are correctly described as positive sexagesimal numbers, typically between 0 and 180 degrees. West longitudes are often confusingly specified as positive numbers between 0 and 180, with a 'W' appended, e.g., +XXX:XX:XX.XX W, or even more confusingly, the W is simply dropped altogether, creating an ambiguity between E and W longitudes. West longitudes should correctly be described as negative numbers between 0 and -180, or equivalently, as positive numbers between 180 and 360. In this document, no distinction is made between E and W longitudes. Where applicable, W longitudes should be passed as negative numbers.

(X, Y, Z): Thompson, Moran and Swenson (Eq. 4.15, 1st ed.) describe a coordinate system for specifying relative antenna locations: they call it (X, Y, Z). In their system, Z lies along the North Celestial Pole, X lies in the plane passing through an arbitrary longitude/latitude point (at 0 Hour Angle), and Y lies at -6h Hour Angle. Thus to convert from a latitude, longitude point to (X, Y, Z), one has only to perform a translation and a latitude rotation. I interpret their XYZ coordinate system to have as its origin the center of the Earth, but there are differing opinions about this. Some think it should be taken to be fixed to the surface at some fiducial point. The two interpretations are simply related by a translation by the radius of the earth, and the difference is irrelevant when dealing with baseline coordinates, since those are always relative.

(U, V, W) : Coordinates tied to the source reference frame (e.g., TMS, section 4.2). These coordinates are simply related to (X, Y, Z) by a rotation of 90-dec about the X axis, followed by a rotation by 90-H about the Z axis, where dec is the source declination and H the hour angle of the source.

(XA, YA, ZA): Same as the (X, Y, Z) system described by TMS, but with X in the plane of the Greenwich meridian, i.e., it is an absolute geocentric coordinate system. getAbsXYZ() takes a longitude, latitude, altitude, and an east, north, up offset relative to that long/lat/alt point, and converts it to an absolute (XA, YA, ZA) vector, in meters. By comparison with XYZ' XYZ coordinate system, to convert from a lat/long/alt point to (XA, YA, ZA), one has to perform a translation, followed by both a longitude rotation and a latitude rotation.

(E, N, U): This coordinate system is useful for specifying locations relative to a given LLA point. Coordinates are in a tangent plane at the specified LLA point, with N pointing due north, E pointing due east, and U pointing straight up along a radial vector from the center of the earth, and passing through the given LLA point. To perform a conversion from UEN to XYZ for example, one has to perform a translation by the Earth's radius, followed by a longitude rotation and a latitude rotation.

This container will natively store coordinates in LLA, hence the constructors which initialize these parameters.

Definition at line 86 of file Coordinates.h.

Member Enumeration Documentation

Enumerate types of distances we might pass to methods.

Definition at line 92 of file Coordinates.h.

Constructor & Destructor Documentation

sza::util::Coordinates::Coordinates ( )

Constructor.

sza::util::Coordinates::Coordinates ( Angle  longitude,
Angle  latitude,
double  altitude 
)

Constructor with initialization of LLA.

Parameters
longitudeAngle Longitude
latitudeAngle Latitude
altitudeAltitude, in meters
sza::util::Coordinates::Coordinates ( Coordinates coord)

Copy constructor.

virtual sza::util::Coordinates::~Coordinates ( )
virtual

Destructor.

Member Function Documentation

static Vector<double> sza::util::Coordinates::absXyzAndUenToLla ( double  XA,
double  YA,
double  ZA,
double  up = 0.0,
double  east = 0.0,
double  north = 0.0 
)
static

Return the LLA of the point given by the specified absolute XYZ and UEN offset.

static Vector<double> sza::util::Coordinates::absXyzToLla ( double  XA,
double  YA,
double  ZA 
)
static

Given absolute XYZ, convert to LLA.

void sza::util::Coordinates::add ( double  up,
double  east,
double  north 
)

Increment the LLA of this object by the specified UEN offset.

static Vector<double> sza::util::Coordinates::azElToUen ( Angle  az,
Angle  el,
double  r = 1.0 
)
static

Given Azimuth and Elevation, return the UEN coordinates.

Note that with r==1.0, this function returns the direction cosines of the position specified by az/el.

static Vector<double> sza::util::Coordinates::dHaDdecToXyz ( HourAngle  dHa,
Angle  dDec 
)
static

Return the (X, Y, Z) coordinates of the specified (Ha, Dec) coordinate.

This function returns the direction cosines only.

Vector<double> sza::util::Coordinates::getAbsXyz ( double  east = 0.0,
double  north = 0.0,
double  up = 0.0 
)

Return absolute XYZ coordinates of the given UEN point, relative to the LLA point of this object.

Vector<Angle> sza::util::Coordinates::getAzEl ( Angle  longitude,
Angle  latitude,
double  altitude 
)

Given a LLA coordinate, return its Az, El relative to the position of this object.

static Vector<double> sza::util::Coordinates::getd2Uvw ( HourAngle  ha,
DecAngle  declination,
double  X,
double  Y,
double  Z 
)
static

Second derivatives of the UVW coordinates wrt time.

(X/s^2)

static Vector<double> sza::util::Coordinates::getdUvw ( HourAngle  ha,
DecAngle  declination,
double  X,
double  Y,
double  Z 
)
static

First derivatives of the UVW coordinates wrt time.

(X/s)

static Delay sza::util::Coordinates::getGeometricDelay ( HourAngle  ha,
DecAngle  declination,
double  X,
double  Y,
double  Z,
double  X0,
double  Y0,
double  Z0,
bool  doMotionCorrection 
)
static

Get the delay for the Ha and Dec of a source, given XYZ coordinates of a baseline.

Note input coordinates should be TMS XYZ, not absolute XYZ.

Note also that the antenna positions should be earth-centered if you want to apply the correction for the earth's motion.

static Delay sza::util::Coordinates::getGeometricDelay ( Angle  latitude,
Angle  az,
Angle  el,
double  X,
double  Y,
double  Z 
)
static

Calculate the delay, in NanoSeconds, for the specified XYZ point, for a source direction given by az/el.

Note: input coordinates should be TMS XYZ, not absolute XYZ

Vector<double> sza::util::Coordinates::getLla ( double  east = 0.0,
double  north = 0.0,
double  up = 0.0 
)

Return LLA of the passed UEN offset point, relative to the LLA coordinates stored in this object.

Vector<double> sza::util::Coordinates::getUen ( Angle  longitude,
Angle  latitude,
double  altitude 
)

Return UEN coordinates of the specified LLA point, relative to the coordinates stored in this object.

Vector<double> sza::util::Coordinates::getUvw ( HourAngle  ha,
DecAngle  declination 
)

Return the UVW coordinates for the current LLA location, of a source at the requested declination and hour angle.

Note that the coordinates in this container refer to an absolute position, or effectively, to a baseline stretching from the origin of the XYZ coordinate system to the location stored in this container, which is the center of the earth.

Vector<double> sza::util::Coordinates::getXyz ( double  east = 0.0,
double  north = 0.0,
double  up = 0.0,
bool  geocentric = true 
)

Return XYZ coordinates of the given UEN point, relative to the LLA point of this object.

static Vector<double> sza::util::Coordinates::haDecAndXyzToUvw ( HourAngle  ha,
DecAngle  declination,
double  X,
double  Y,
double  Z 
)
static

Return the UVW coordinates, relative to a given XYZ coordinate, for the requested source position.

Note that if the passed XYZ coordinates are the (relative) coordinates of a baseline, you will get the UVW coordinates relative to the origin of your baseline. If the passed XYZ coordinates are actual antenna coordinates, you will get the UVW coordinates relative to the origin of the XYZ coordinate system.

static Vector<double> sza::util::Coordinates::haDecToXyz ( HourAngle  ha,
DecAngle  declination,
bool  geocentric = true,
SrcDist  type = INF,
double  r = 0.0 
)
static

Return the XYZ coordinate of a vector at requested (Ha, Dec) direction and of length r.

Parameters
geocentricIf true, return geocentric (X, Y, Z). If false, returned coordinates will be topocentric.
typeIf ACTUAL, interpret r to mean an actual distance (in AU). If INF, ignore r and return the source direction only.
static Vector<Angle> sza::util::Coordinates::laAndHaDecToAzEl ( Angle  latitude,
double  altitude,
HourAngle  ha,
DecAngle  declination,
bool  geocentric = true,
SrcDist  type = INF,
double  dist = 1.0 
)
static

Return the Az El of a source at a given HA and Dec.

Parameters
latitudeThe latitude wrt to which the coordinates are desired
altitudeThe altitude wrt to which the coordinates are desired
haThe HA of the source, wrt the point of observation
declinationThe declination of the source.
geocentricIf true, the Az, El returned will be geocentric. If false, the Az, El returned will be topocentric. Note that if you request topocentric Az/El, you do not need to correct the returned values for horizontal parallax. Horizontal parallax is the correction between geocentric and topocentric Az/El.
typeIf ACTUAL, interpret r to mean an actual distance (in AU). If INF, ignore r and return the source direction only.
static Vector<double> sza::util::Coordinates::laAndUenToXyz ( Angle  latitude,
double  altitude,
double  up = 0.0,
double  east = 0.0,
double  north = 0.0,
bool  geocentric = true 
)
static

Return the XYZ coordinates of an UEN point relative to a fiducial LA.

Note that no longitude is required, as the X-Z plane of the XYZ coordinate system always lies in the local meridian.

If geocentric==true, the origin of the returned XYZ coordinates will be the center of the earth. If false, the origin will be at the fiducial point on the surface. Use whichever definition pleases you – you'd better get identical results for a baseline specified in either system, since those coordinates are always relative.

static Vector<double> sza::util::Coordinates::llaAndLlaToUen ( Angle  fiducialLongitude,
Angle  fiducialLatitude,
double  fiducialAltitude,
Angle  longitude,
Angle  latitude,
double  altitude 
)
static

Return the UEN of an LLA point relative to a fiducial LLA point.

static Vector<double> sza::util::Coordinates::llaAndUenToAbsXyz ( Angle  longitude,
Angle  latitude,
double  altitude,
double  up,
double  east,
double  north,
bool  doTrans = true 
)
static

Return absolute XYZ of the point offset by UEN from a given LLA point.

static Vector<double> sza::util::Coordinates::llaAndUenToLla ( Angle  longitude,
Angle  latitude,
double  altitude,
double  up,
double  east,
double  north 
)
static

Return the LLA of the point given by an UEN offset relative to a fiducial LLA.

static Vector<double> sza::util::Coordinates::lngLatAndAzElToLngLat ( Angle &  lng,
Angle &  lat,
Angle &  az,
Angle &  el 
)
static

Return the LL of the point given by an az/el offset relative to a fiducial LL.

Angle& sza::util::Coordinates::longitude ( )

Position return methods.

Definition at line 144 of file Coordinates.h.

static void sza::util::Coordinates::raDecAndThetaRhoToRaDec ( HourAngle &  ra0,
Declination &  dec0,
Angle &  theta,
Angle &  rho,
HourAngle &  ra,
Declination &  dec 
)
static

......................................................................

Given fiducial position on the sky (assumed to be at 0h), and a polar offset (theta, rho) from it (where theta is measured clockwise looking out on the sky), return the ra, dec coordinates of the new location.

void sza::util::Coordinates::setAltitude ( double  altitude)

Set just the altitude.

void sza::util::Coordinates::setLatitude ( Angle  latitude)

Set just the latitude.

void sza::util::Coordinates::setLla ( Angle  longitude,
Angle  latitude,
double  altitude 
)

Set methods.

void sza::util::Coordinates::setLongitude ( Angle  longitude)

Set just the longitude.

static Vector<double> sza::util::Coordinates::topoXYZToUen ( double  X,
double  Y,
double  Z,
Angle  latitude 
)
static

Given a topocentric XYZ, return the UEN coordinates at a given latitude.

static Vector<Angle> sza::util::Coordinates::uenToAzEl ( double  U,
double  E,
double  N 
)
static

Given UEN, return the Azimuth and Elevation.

static void sza::util::Coordinates::xyzToDhaDdec ( double  X,
double  Y,
double  Z,
HourAngle &  dHa,
Angle &  dDec 
)
static

Return the dHa and dDec corresponding to the specified (X, Y, Z) coordinate.

static void sza::util::Coordinates::xyzToDhaDdec ( Vector< double > &  xyzVals,
HourAngle &  dHa,
Angle &  dDec 
)
static

Return the dHa and dDec corresponding to the specified (X, Y, Z) coordinate.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Coordinates coords 
)
friend

Allows cout << coords.

Member Data Documentation

const double sza::util::Coordinates::auToMeters_
static

Conversion between AU and meters.

Definition at line 460 of file Coordinates.h.

const double sza::util::Coordinates::earthFlattening_
static

Flattening of the earth.

Definition at line 450 of file Coordinates.h.

const double sza::util::Coordinates::earthRotVelRadPerSec_
static

Rotational angular velocity of the earth, in radians per second.

Definition at line 466 of file Coordinates.h.


The documentation for this class was generated from the following file: