LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::afw::coord::Coord Class Reference

#include <Coord.h>

Inheritance diagram for lsst::afw::coord::Coord:
lsst::afw::coord::EclipticCoord lsst::afw::coord::Fk5Coord lsst::afw::coord::GalacticCoord lsst::afw::coord::IcrsCoord lsst::afw::coord::TopocentricCoord

Public Types

typedef boost::shared_ptr< CoordPtr
 
typedef boost::shared_ptr
< Coord const > 
ConstPtr
 

Public Member Functions

 Coord (lsst::afw::geom::Point2D const &p2d, lsst::afw::geom::AngleUnit unit=lsst::afw::geom::degrees, double const epoch=2000.0)
 Constructor for the Coord base class. More...
 
 Coord (lsst::afw::geom::Point3D const &p3d, double const epoch=2000.0, bool normalize=true, lsst::afw::geom::Angle const defaultLongitude=lsst::afw::geom::Angle(0.))
 Constructor for the Coord base class. More...
 
 Coord (lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch=2000.0)
 Constructor for the Coord base class. More...
 
 Coord (std::string const ra, std::string const dec, double const epoch=2000.0)
 Constructor for the Coord base class. More...
 
 Coord ()
 Default constructor for the Coord base class. More...
 
virtual ~Coord ()
 
virtual Coord::Ptr clone () const
 
virtual void reset (lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
 
virtual void reset (lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude, double const epoch)
 Reset our coordinates wholesale. More...
 
double getEpoch () const
 
lsst::afw::geom::Point2D getPosition (lsst::afw::geom::AngleUnit unit=lsst::afw::geom::degrees) const
 Return our contents in a Point2D object. More...
 
lsst::afw::geom::Point3D getVector () const
 Return our contents in a position vector. More...
 
virtual std::pair< std::string,
std::string > 
getCoordNames () const
 
virtual std::string getClassName () const
 
lsst::afw::geom::Angle operator[] (int const index) const
 Provide access to our contents via an index. More...
 
bool operator== (Coord const &rhs) const
 Equality operator, compares each element directly. More...
 
lsst::afw::geom::Angle getLongitude () const
 The main access method for the longitudinal coordinate. More...
 
lsst::afw::geom::Angle getLatitude () const
 The main access method for the latitudinal coordinate. More...
 
std::string getLongitudeStr (lsst::afw::geom::AngleUnit unit) const
 Allow quick access to the longitudinal coordinate as a string. More...
 
std::string getLatitudeStr () const
 Allow quick access to the longitude coordinate as a string. More...
 
Coord transform (Coord const &poleFrom, Coord const &poleTo) const
 Tranform our current coords to another spherical polar system. More...
 
lsst::afw::geom::Angle angularSeparation (Coord const &c) const
 compute the angular separation between two Coords More...
 
std::pair
< lsst::afw::geom::Angle,
lsst::afw::geom::Angle
getOffsetFrom (Coord const &c) const
 Compute the offset from a coordinate. More...
 
std::pair
< lsst::afw::geom::Angle,
lsst::afw::geom::Angle
getTangentPlaneOffset (Coord const &c) const
 Get the offset on the tangent plane. More...
 
void rotate (Coord const &axis, lsst::afw::geom::Angle const theta)
 Rotate our current coords about a pole. More...
 
lsst::afw::geom::Angle offset (lsst::afw::geom::Angle const phi, lsst::afw::geom::Angle const arcLen)
 offset our current coords along a great circle defined by an angle wrt a declination parallel More...
 
Coord::Ptr convert (CoordSystem system) const
 Convert to a specified Coord type. More...
 
virtual Fk5Coord toFk5 (double const epoch) const
 Convert ourself to Fk5: RA, Dec (precess to new epoch) More...
 
virtual Fk5Coord toFk5 () const
 Convert ourself to Fk5: RA, Dec (use current epoch) More...
 
virtual IcrsCoord toIcrs () const
 Convert ourself to ICRS: RA, Dec (basically J2000) More...
 
virtual GalacticCoord toGalactic () const
 Convert ourself to Galactic: l, b. More...
 
virtual EclipticCoord toEcliptic (double const epoch) const
 Convert ourself to Ecliptic: lambda, beta (precess to new epoch) More...
 
virtual EclipticCoord toEcliptic () const
 Convert ourself to Ecliptic: lambda, beta (use existing epoch) More...
 
virtual TopocentricCoord toTopocentric (Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
 Convert ourself to Altitude/Azimuth: alt, az. More...
 

Private Member Functions

void _verifyValues () const
 Make sure the values we've got are in the range 0 <= x < 2PI. More...
 

Private Attributes

lsst::afw::geom::Angle _longitude
 
lsst::afw::geom::Angle _latitude
 
double _epoch
 

Detailed Description

This is the base class for spherical coordinates.

Definition at line 69 of file Coord.h.

Member Typedef Documentation

typedef boost::shared_ptr<Coord const> lsst::afw::coord::Coord::ConstPtr

Definition at line 73 of file Coord.h.

typedef boost::shared_ptr<Coord> lsst::afw::coord::Coord::Ptr

Definition at line 72 of file Coord.h.

Constructor & Destructor Documentation

lsst::afw::coord::Coord::Coord ( lsst::afw::geom::Point2D const &  p2d,
lsst::afw::geom::AngleUnit  unit = lsst::afw::geom::degrees,
double const  epoch = 2000.0 
)

Constructor for the Coord base class.

Parameters
p2dPoint2D
unitRads, Degs, or Hrs
epochepoch of coordinate

Definition at line 373 of file Coord.cc.

377  :
378  _longitude(NaN), _latitude(NaN), _epoch(epoch) {
379  _longitude = afwGeom::Angle(p2d.getX(), unit);
380  _longitude.wrap();
381  _latitude = afwGeom::Angle(p2d.getY(), unit);
382  _verifyValues();
383 }
lsst::afw::geom::Angle Angle
Definition: misc.h:39
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 &lt;= x &lt; 2PI.
Definition: Coord.cc:447
lsst::afw::coord::Coord::Coord ( lsst::afw::geom::Point3D const &  p3d,
double const  epoch = 2000.0,
bool  normalize = true,
lsst::afw::geom::Angle const  defaultLongitude = lsst::afw::geom::Angle(0.) 
)

Constructor for the Coord base class.

Parameters
p3dPoint3D
epochepoch of coordinate
normalizenormalize the p3d provided
defaultLongitudelongitude to use if x=y=0

Definition at line 388 of file Coord.cc.

393  :
396  _epoch(epoch) {
397 
398  std::pair<afwGeom::Angle, afwGeom::Angle> lonLat = pointToLonLat(p3d, defaultLongitude, normalize);
399  _longitude = lonLat.first;
400  _latitude = lonLat.second;
401  _epoch = epoch;
402 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
lsst::afw::coord::Coord::Coord ( lsst::afw::geom::Angle const  ra,
lsst::afw::geom::Angle const  dec,
double const  epoch = 2000.0 
)

Constructor for the Coord base class.

Parameters
raRight ascension, decimal degrees
decDeclination, decimal degrees
epochepoch of coordinate

Definition at line 408 of file Coord.cc.

412  :
413  _longitude(ra), _latitude(dec), _epoch(epoch) {
414  _longitude.wrap();
415  _verifyValues();
416 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 &lt;= x &lt; 2PI.
Definition: Coord.cc:447
lsst::afw::coord::Coord::Coord ( std::string const  ra,
std::string const  dec,
double const  epoch = 2000.0 
)

Constructor for the Coord base class.

Parameters
raRight ascension, hh:mm:ss.s format
decDeclination, dd:mm:ss.s format
epochepoch of coordinate

Definition at line 422 of file Coord.cc.

426  :
429  _epoch(epoch) {
430  _longitude.wrap();
431  _verifyValues();
432 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle hmsStringToAngle(std::string const hms)
Convert a hh:mm:ss string to Angle.
Definition: Coord.cc:335
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 &lt;= x &lt; 2PI.
Definition: Coord.cc:447
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:344
lsst::afw::coord::Coord::Coord ( )

Default constructor for the Coord base class.

Set all values to NaN Don't call _veriftyValues() method ... it'll fail.

Definition at line 441 of file Coord.cc.

lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
virtual lsst::afw::coord::Coord::~Coord ( )
inlinevirtual

Definition at line 82 of file Coord.h.

82 {}

Member Function Documentation

void lsst::afw::coord::Coord::_verifyValues ( ) const
private

Make sure the values we've got are in the range 0 <= x < 2PI.

Definition at line 447 of file Coord.cc.

447  {
449  throw LSST_EXCEPT(ex::InvalidParameterError,
450  (boost::format("Latitude coord must be: -PI/2 <= lat <= PI/2 (%f).") %
451  _latitude).str());
452  }
453 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
double asRadians() const
Definition: Angle.h:122
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
double const HALFPI
Definition: Angle.h:20
afwGeom::Angle lsst::afw::coord::Coord::angularSeparation ( Coord const &  c) const

compute the angular separation between two Coords

Parameters
ccoordinate to compute our separation from

Definition at line 689 of file Coord.cc.

691  {
692 
693  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
694  // we'll put them in the same system.
695  std::pair<afwCoord::Fk5Coord, afwCoord::Fk5Coord> const& fk5 = commonFk5(*this, c);
696  afwGeom::Angle const alpha1 = fk5.first.getRa();
697  afwGeom::Angle const delta1 = fk5.first.getDec();
698  afwGeom::Angle const alpha2 = fk5.second.getRa();
699  afwGeom::Angle const delta2 = fk5.second.getDec();
700 
701  return haversine(alpha1 - alpha2, delta1 - delta2, std::cos(delta1), std::cos(delta2));
702 }
virtual Coord::Ptr lsst::afw::coord::Coord::clone ( ) const
inlinevirtual

Reimplemented in lsst::afw::coord::TopocentricCoord, lsst::afw::coord::EclipticCoord, lsst::afw::coord::GalacticCoord, lsst::afw::coord::Fk5Coord, and lsst::afw::coord::IcrsCoord.

Definition at line 84 of file Coord.h.

84 { return Coord::Ptr(new Coord(*this)); }
boost::shared_ptr< Coord > Ptr
Definition: Coord.h:72
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:441
afwCoord::Coord::Ptr lsst::afw::coord::Coord::convert ( CoordSystem  system) const

Convert to a specified Coord type.

Definition at line 637 of file Coord.cc.

637  {
638 
639  switch (system) {
640  case FK5:
641  {
642  Fk5Coord c1 = this->toFk5();
643  return boost::shared_ptr<Fk5Coord>(new Fk5Coord(c1.getLongitude(),
644  c1.getLatitude(),
645  c1.getEpoch()));
646  }
647  break;
648  case ICRS:
649  {
650  IcrsCoord c2 = this->toIcrs();
651  return boost::shared_ptr<IcrsCoord>(new IcrsCoord(c2.getLongitude(),
652  c2.getLatitude()));
653  }
654  break;
655  case GALACTIC:
656  {
657  GalacticCoord c4 = this->toGalactic();
658  return boost::shared_ptr<GalacticCoord>(new GalacticCoord(c4.getLongitude(),
659  c4.getLatitude()));
660  }
661  break;
662  case ECLIPTIC:
663  {
664  EclipticCoord c5 = this->toEcliptic();
665  return boost::shared_ptr<EclipticCoord>(new EclipticCoord(c5.getLongitude(),
666  c5.getLatitude(),
667  c5.getEpoch()));
668  }
669  break;
670  case TOPOCENTRIC:
671  throw LSST_EXCEPT(ex::InvalidParameterError,
672  "Cannot make Topocentric with convert() (must also specify Observatory).\n"
673  "Instantiate TopocentricCoord() directly.");
674  break;
675  default:
676  throw LSST_EXCEPT(ex::InvalidParameterError,
677  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC allowed.");
678  break;
679 
680  }
681 
682 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:799
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:38
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use existing epoch)
Definition: Coord.cc:812
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:792
virtual std::string lsst::afw::coord::Coord::getClassName ( ) const
inlinevirtual
virtual std::pair<std::string, std::string> lsst::afw::coord::Coord::getCoordNames ( ) const
inlinevirtual

Reimplemented in lsst::afw::coord::TopocentricCoord, lsst::afw::coord::EclipticCoord, and lsst::afw::coord::GalacticCoord.

Definition at line 97 of file Coord.h.

97  {
98  return std::pair<std::string, std::string>("RA", "Dec");
99  }
double lsst::afw::coord::Coord::getEpoch ( ) const
inline

Definition at line 93 of file Coord.h.

93 { return _epoch; }
lsst::afw::geom::Angle lsst::afw::coord::Coord::getLatitude ( ) const
inline

The main access method for the latitudinal coordinate.

All systems store their latitudinal coordinate in _latitude, be it Dec, b, beta, or altitude. This is how they're accessed.

Definition at line 120 of file Coord.h.

120 { return _latitude; };
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
std::string lsst::afw::coord::Coord::getLatitudeStr ( ) const
inline

Allow quick access to the longitude coordinate as a string.

Note
There's no reason to want a latitude in radians or hours, so the units can not be explicitly requested.

Definition at line 460 of file Coord.h.

460  {
461  return angleToDmsString(getLatitude());
462 }
std::string angleToDmsString(lsst::afw::geom::Angle const deg)
a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss ...
Definition: Coord.cc:293
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120
lsst::afw::geom::Angle lsst::afw::coord::Coord::getLongitude ( ) const
inline

The main access method for the longitudinal coordinate.

All systems store their longitudinal coordinate in _longitude, be it RA, l, lambda, or azimuth. This is how they're accessed.

Definition at line 113 of file Coord.h.

113 { return _longitude; };
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
std::string lsst::afw::coord::Coord::getLongitudeStr ( lsst::afw::geom::AngleUnit  unit) const
inline

Allow quick access to the longitudinal coordinate as a string.

Note
There's no reason to want a longitude in radians, so that unit will cause an exception to be thrown
There's no clear winner for a default, so the unit must always be explicitly provided.

Definition at line 443 of file Coord.h.

443  {
444  if (unit == lsst::afw::geom::hours) {
445  return angleToHmsString(getLongitude());
446  } else if (unit == lsst::afw::geom::degrees) {
447  return angleToDmsString(getLongitude());
448  } else {
449  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
450  "Units must be 'degrees' or 'hours'");
451  }
452 }
AngleUnit const hours
Definition: Angle.h:93
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
std::string angleToDmsString(lsst::afw::geom::Angle const deg)
a Function to convert a coordinate in decimal degrees to a string with form dd:mm:ss ...
Definition: Coord.cc:293
std::string angleToHmsString(lsst::afw::geom::Angle const deg)
a function to convert decimal degrees to a string with form hh:mm:ss.s
Definition: Coord.cc:300
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
AngleUnit const degrees
Definition: Angle.h:92
std::pair< afwGeom::Angle, afwGeom::Angle > lsst::afw::coord::Coord::getOffsetFrom ( afwCoord::Coord const &  c) const

Compute the offset from a coordinate.

The resulting angles are suitable for input to Coord::offset

Returns
pair of Angles: bearing (angle wrt a declination parallel) and distance
Parameters
cCoordinate from which to compute offset

Definition at line 713 of file Coord.cc.

715 {
716  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
717  // we'll put them in the same system.
718  std::pair<afwCoord::Fk5Coord, afwCoord::Fk5Coord> const& fk5 = commonFk5(*this, c);
719  afwGeom::Angle const alpha1 = fk5.first.getRa();
720  afwGeom::Angle const delta1 = fk5.first.getDec();
721  afwGeom::Angle const alpha2 = fk5.second.getRa();
722  afwGeom::Angle const delta2 = fk5.second.getDec();
723 
724  afwGeom::Angle const dAlpha = alpha1-alpha2;
725  afwGeom::Angle const dDelta = delta1-delta2;
726 
727  double const cosDelta1 = std::cos(delta1);
728  double const cosDelta2 = std::cos(delta2);
729 
730  afwGeom::Angle separation = haversine(dAlpha, dDelta, cosDelta1, cosDelta2);
731 
732  // Formula from http://www.movable-type.co.uk/scripts/latlong.html
733  double const y = std::sin(dAlpha)*cosDelta2;
734  double const x = cosDelta1*std::sin(delta2) - std::sin(delta1)*cosDelta2*std::cos(dAlpha);
735  afwGeom::Angle bearing = std::atan2(y, x)*afwGeom::radians - 90.0*afwGeom::degrees;
736 
737  return std::make_pair(bearing, separation);
738 }
int y
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
double x
AngleUnit const degrees
Definition: Angle.h:92
afwGeom::Point2D lsst::afw::coord::Coord::getPosition ( lsst::afw::geom::AngleUnit  unit = lsst::afw::geom::degrees) const

Return our contents in a Point2D object.

Definition at line 477 of file Coord.cc.

477  {
478  // treat HOURS specially, they must mean hours for RA, degrees for Dec
479  if (unit == afwGeom::hours) {
480  return afwGeom::Point2D(getLongitude().asHours(), getLatitude().asDegrees());
481  } else {
482  return afwGeom::Point2D(getLongitude().asAngularUnits(unit), getLatitude().asAngularUnits(unit));
483  }
484 }
AngleUnit const hours
Definition: Angle.h:93
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
Point< double, 2 > Point2D
Definition: Point.h:286
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120
std::pair< afwGeom::Angle, afwGeom::Angle > lsst::afw::coord::Coord::getTangentPlaneOffset ( afwCoord::Coord const &  c) const

Get the offset on the tangent plane.

This is suitable only for small angles.

Returns
pair of Angles: Longitude and Latitude offsets
Parameters
cCoordinate from which to compute offset

Definition at line 748 of file Coord.cc.

750 {
751  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
752  // we'll put them in the same system.
753  std::pair<afwCoord::Fk5Coord, afwCoord::Fk5Coord> const& fk5 = commonFk5(*this, c);
754  afwGeom::Angle const alpha1 = fk5.first.getRa();
755  afwGeom::Angle const delta1 = fk5.first.getDec();
756  afwGeom::Angle const alpha2 = fk5.second.getRa();
757  afwGeom::Angle const delta2 = fk5.second.getDec();
758 
759  // This is a projection of coord2 to the tangent plane at coord1
760  double const sinDelta1 = std::sin(delta1);
761  double const cosDelta1 = std::cos(delta1);
762  double const sinDelta2 = std::sin(delta2);
763  double const cosDelta2 = std::cos(delta2);
764  double const cosAlphaDiff = std::cos(alpha2 - alpha1);
765  double const sinAlphaDiff = std::sin(alpha2 - alpha1);
766 
767  double const div = cosDelta1 * cosAlphaDiff * cosDelta2 + sinDelta1 * sinDelta2;
768  double const xi = cosDelta1 * sinAlphaDiff / div;
769  double const eta = (cosDelta1 * cosAlphaDiff * sinDelta2 - sinDelta1 * cosDelta2) / div;
770 
771  return std::make_pair(xi*afwGeom::radians, eta*afwGeom::radians);
772 }
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
afwGeom::Point3D lsst::afw::coord::Coord::getVector ( ) const

Return our contents in a position vector.

Definition at line 491 of file Coord.cc.

491  {
492  double lng = getLongitude();
493  double lat = getLatitude();
494  double const x = std::cos(lng) * std::cos(lat);
495  double const y = std::sin(lng) * std::cos(lat);
496  double const z = std::sin(lat);
497  return afwGeom::Point3D(x, y, z);
498 }
int y
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
Point< double, 3 > Point3D
Definition: Point.h:287
double x
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120
afwGeom::Angle lsst::afw::coord::Coord::offset ( lsst::afw::geom::Angle const  phi,
lsst::afw::geom::Angle const  arcLen 
)

offset our current coords along a great circle defined by an angle wrt a declination parallel

Note
At/near the pole, longitude becomes degenerate with angle-wrt-declination. So at the pole the offset will trace a meridian with longitude = 90 + longitude0 + phi
Returns
the angle wrt a declination parallel at new position
Parameters
phiangle wrt parallel to offset
arcLenangle to offset

Definition at line 566 of file Coord.cc.

569  {
570 
571  // let v = vector in the direction arcLen points (tangent to surface of sphere)
572  // thus: |v| = arcLen
573  // angle phi = orientation of v in a tangent plane, measured wrt to a parallel of declination
574 
575  // To do the rotation, use rotate() method.
576  // - must provide an axis of rotation: take the cross product r x v to get that axis (pole)
577 
578  // get the vector r
579  Eigen::Vector3d r = getVector().asEigen();
580 
581  // Get the vector v:
582  // let u = unit vector lying on a parallel of declination
583  // let w = unit vector along line of longitude = r x u
584  // the vector v must satisfy the following:
585  // |v| = arcLen
586  // r . v = 0
587  // u . v = |v| cos(phi) = arcLen*cos(phi)
588  // w . v = |v| sin(phi) = arcLen*sin(phi)
589 
590  // v is a linear combination of u and w
591  // v = arcLen*cos(phi)*u + arcLen*sin(phi)*w
592 
593  // Thus, we must:
594  // - create u vector
595  // - solve w vector (r cross u)
596  // - compute v
597  Eigen::Vector3d u;
598  u << -std::sin(getLongitude()), std::cos(getLongitude()), 0.0;
599  Eigen::Vector3d w = r.cross(u);
600  Eigen::Vector3d v = arcLen * std::cos(phi)*u + arcLen * std::sin(phi)*w;
601 
602  // take r x v to get the axis
603  Eigen::Vector3d axisVector = r.cross(v);
604  axisVector.normalize();
605  Coord axisCoord = Coord(afwGeom::Point3D(axisVector), getEpoch());
606 
607  rotate(axisCoord, arcLen);
608 
609  // now get the position angle at our destination
610  // u2 . v2 = arcLen*cos(phi2)
611  // w2 . v2 = arcLen*sin(phi2)
612  // if we normalize v2:
613  // phi2 = atan2(w2.v2, u2.v2)
614  //
615  // we need to compute u2, and then rotate v (exactly as we rotated r) to get v2
616  Eigen::Vector3d r2 = getVector().asEigen();
617  Eigen::Vector3d u2;
618  u2 << -std::sin(getLongitude()), std::cos(getLongitude()), 0.0;
619  Eigen::Vector3d w2 = r2.cross(u2);
620 
621  // make v a unit vector and rotate v exactly as we rotated r
622  v.normalize();
623  Coord v2Coord = Coord(afwGeom::Point3D(v), getEpoch());
624  v2Coord.rotate(axisCoord, arcLen);
625  Eigen::Vector3d v2 = v2Coord.getVector().asEigen();
626 
627  afwGeom::Angle phi2 = std::atan2(w2.dot(v2), u2.dot(v2)) * afwGeom::radians;
628 
629  return phi2;
630 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
A coordinate class intended to represent absolute positions.
void rotate(Coord const &axis, lsst::afw::geom::Angle const theta)
Rotate our current coords about a pole.
Definition: Coord.cc:529
double w
Definition: CoaddPsf.cc:57
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:491
double getEpoch() const
Definition: Coord.h:93
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:441
bool lsst::afw::coord::Coord::operator== ( Coord const &  rhs) const
inline

Equality operator, compares each element directly.

Definition at line 467 of file Coord.h.

467  {
468  return (_longitude == rhs._longitude) &&
469  (_latitude == rhs._latitude) &&
470  (_epoch == rhs._epoch);
471 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
lsst::afw::geom::Angle lsst::afw::coord::Coord::operator[] ( int const  index) const
inline

Provide access to our contents via an index.

Definition at line 418 of file Coord.h.

418  {
419 
420  switch (index) {
421  case 0:
422  return _longitude;
423  break;
424  case 1:
425  return _latitude;
426  break;
427  default:
428  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError,
429  "Index must be 0 or 1.");
430  break;
431  }
432 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
#define LSST_EXCEPT(type,...)
Definition: Exception.h:46
virtual void lsst::afw::coord::Coord::reset ( lsst::afw::geom::Angle const  longitude,
lsst::afw::geom::Angle const  latitude 
)
inlinevirtual

Reimplemented in lsst::afw::coord::GalacticCoord, and lsst::afw::coord::IcrsCoord.

Definition at line 86 of file Coord.h.

86  {
87  double const epoch = 2000.0;
88  reset(longitude, latitude, epoch);
89  }
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
Definition: Coord.h:86
void lsst::afw::coord::Coord::reset ( lsst::afw::geom::Angle const  longitude,
lsst::afw::geom::Angle const  latitude,
double const  epoch 
)
virtual

Reset our coordinates wholesale.

This allows the user to instantiate Coords without values, and fill them later.

Parameters
longitudeLongitude coord (eg. R.A. for Fk5)
latitudeLatitude coord (eg. Declination for Fk5)
epochepoch of coordinate

Definition at line 460 of file Coord.cc.

464  {
465  _longitude = longitude;
466  _latitude = latitude;
467  _longitude.wrap();
468  _epoch = epoch;
469  _verifyValues();
470 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 &lt;= x &lt; 2PI.
Definition: Coord.cc:447
void lsst::afw::coord::Coord::rotate ( Coord const &  axis,
lsst::afw::geom::Angle const  theta 
)

Rotate our current coords about a pole.

Parameters
axisaxis of rotation (right handed)
thetaangle to offset in radians

Definition at line 529 of file Coord.cc.

532  {
533 
534  double const c = std::cos(theta);
535  double const mc = 1.0 - c;
536  double const s = std::sin(theta);
537 
538  // convert to cartesian
539  afwGeom::Point3D const x = getVector();
540  afwGeom::Point3D const u = axis.getVector();
541  double const ux = u[0];
542  double const uy = u[1];
543  double const uz = u[2];
544 
545  // rotate
546  afwGeom::Point3D xprime;
547  xprime[0] = (ux*ux + (1.0 - ux*ux)*c)*x[0] + (ux*uy*mc - uz*s)*x[1] + (ux*uz*mc + uy*s)*x[2];
548  xprime[1] = (uy*uy + (1.0 - uy*uy)*c)*x[1] + (uy*uz*mc - ux*s)*x[2] + (ux*uy*mc + uz*s)*x[0];
549  xprime[2] = (uz*uz + (1.0 - uz*uz)*c)*x[2] + (uz*ux*mc - uy*s)*x[0] + (uy*uz*mc + ux*s)*x[1];
550 
551  // in-situ
552  std::pair<afwGeom::Angle, afwGeom::Angle> lonLat = pointToLonLat(xprime);
553  _longitude = lonLat.first;
554  _latitude = lonLat.second;
555 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:147
lsst::afw::geom::Angle _longitude
Definition: Coord.h:146
A coordinate class intended to represent absolute positions.
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:491
double x
afwCoord::EclipticCoord lsst::afw::coord::Coord::toEcliptic ( double const  epoch) const
virtual

Convert ourself to Ecliptic: lambda, beta (precess to new epoch)

Reimplemented in lsst::afw::coord::EclipticCoord, and lsst::afw::coord::Fk5Coord.

Definition at line 806 of file Coord.cc.

806  {
807  return this->toFk5(epoch).toEcliptic();
808 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual EclipticCoord toEcliptic(double const epoch) const
Convert ourself to Ecliptic: lambda, beta (precess to new epoch)
Definition: Coord.cc:886
afwCoord::EclipticCoord lsst::afw::coord::Coord::toEcliptic ( ) const
virtual

Convert ourself to Ecliptic: lambda, beta (use existing epoch)

Reimplemented in lsst::afw::coord::EclipticCoord, and lsst::afw::coord::Fk5Coord.

Definition at line 812 of file Coord.cc.

812  {
813  return this->toFk5().toEcliptic();
814 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual EclipticCoord toEcliptic(double const epoch) const
Convert ourself to Ecliptic: lambda, beta (precess to new epoch)
Definition: Coord.cc:886
afwCoord::Fk5Coord lsst::afw::coord::Coord::toFk5 ( double const  epoch) const
virtual

Convert ourself to Fk5: RA, Dec (precess to new epoch)

Reimplemented in lsst::afw::coord::TopocentricCoord, lsst::afw::coord::EclipticCoord, lsst::afw::coord::GalacticCoord, lsst::afw::coord::Fk5Coord, and lsst::afw::coord::IcrsCoord.

Definition at line 778 of file Coord.cc.

778  {
779  return Fk5Coord(getLongitude(), getLatitude(), getEpoch()).precess(epoch);
780 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
double getEpoch() const
Definition: Coord.h:93
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120
afwCoord::Fk5Coord lsst::afw::coord::Coord::toFk5 ( ) const
virtual

Convert ourself to Fk5: RA, Dec (use current epoch)

Reimplemented in lsst::afw::coord::TopocentricCoord, lsst::afw::coord::EclipticCoord, lsst::afw::coord::GalacticCoord, lsst::afw::coord::Fk5Coord, and lsst::afw::coord::IcrsCoord.

Definition at line 784 of file Coord.cc.

784  {
785  return Fk5Coord(getLongitude(), getLatitude(), getEpoch());
786 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
double getEpoch() const
Definition: Coord.h:93
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120
afwCoord::GalacticCoord lsst::afw::coord::Coord::toGalactic ( ) const
virtual

Convert ourself to Galactic: l, b.

Reimplemented in lsst::afw::coord::GalacticCoord, and lsst::afw::coord::Fk5Coord.

Definition at line 799 of file Coord.cc.

799  {
800  return this->toFk5().toGalactic();
801 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:868
afwCoord::IcrsCoord lsst::afw::coord::Coord::toIcrs ( ) const
virtual

Convert ourself to ICRS: RA, Dec (basically J2000)

Reimplemented in lsst::afw::coord::Fk5Coord, and lsst::afw::coord::IcrsCoord.

Definition at line 792 of file Coord.cc.

792  {
793  return this->toFk5().toIcrs();
794 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:853
afwCoord::TopocentricCoord lsst::afw::coord::Coord::toTopocentric ( Observatory const &  obs,
lsst::daf::base::DateTime const &  obsDate 
) const
virtual

Convert ourself to Altitude/Azimuth: alt, az.

Parameters
obsobservatory of observation
obsDatedate of observation

Reimplemented in lsst::afw::coord::TopocentricCoord, and lsst::afw::coord::Fk5Coord.

Definition at line 819 of file Coord.cc.

822  {
823  return this->toFk5().toTopocentric(obs, obsDate);
824 }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:784
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
Definition: Coord.cc:903
afwCoord::Coord lsst::afw::coord::Coord::transform ( Coord const &  poleTo,
Coord const &  poleFrom 
) const

Tranform our current coords to another spherical polar system.

Variable names assume an equaltorial/galactic tranform, but it works for any spherical polar system when the appropriate poles are supplied.

Parameters
poleToPole of the destination system in the current coords
poleFromPole of the current system in the destination coords

Definition at line 507 of file Coord.cc.

510  {
511  double const alphaGP = poleFrom[0];
512  double const deltaGP = poleFrom[1];
513  double const lCP = poleTo[0];
514 
515  double const alpha = getLongitude();
516  double const delta = getLatitude();
517 
518  afwGeom::Angle const l = (lCP - std::atan2(std::sin(alpha - alphaGP),
519  std::tan(delta)*std::cos(deltaGP) - std::cos(alpha - alphaGP)*std::sin(deltaGP))) * afwGeom::radians;
520  afwGeom::Angle const b = std::asin( (std::sin(deltaGP)*std::sin(delta) + std::cos(deltaGP)*std::cos(delta)*std::cos(alpha - alphaGP))) * afwGeom::radians;
521  return Coord(l, b);
522 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:113
Matrix alpha
AngleUnit const radians
constant with units of radians
Definition: Angle.h:91
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:441
afw::table::Key< double > b
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:120

Member Data Documentation

double lsst::afw::coord::Coord::_epoch
private

Definition at line 148 of file Coord.h.

lsst::afw::geom::Angle lsst::afw::coord::Coord::_latitude
private

Definition at line 147 of file Coord.h.

lsst::afw::geom::Angle lsst::afw::coord::Coord::_longitude
private

Definition at line 146 of file Coord.h.


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