LSSTApplications  11.0-24-g0a022a1,14.0+77,15.0,15.0+1
LSSTDataManagementBasePackage
Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::afw::coord::Coord Class Reference

This is the base class for spherical coordinates. More...

#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 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 ()=default
 
 Coord (Coord const &)
 
 Coord (Coord &&)
 
Coordoperator= (Coord const &)
 
Coordoperator= (Coord &&)
 
virtual std::shared_ptr< Coordclone () 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::stringgetCoordNames () const
 
virtual std::string getClassName () const
 
virtual CoordSystem getCoordSystem () const
 
virtual std::string toString () const
 Get string representation. More...
 
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 &poleTo, Coord const &poleFrom) const
 Transform 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::AnglegetOffsetFrom (Coord const &c) const
 Compute the offset from a coordinate. More...
 
std::pair< lsst::afw::geom::Angle, lsst::afw::geom::AnglegetTangentPlaneOffset (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...
 
std::shared_ptr< Coordconvert (CoordSystem system, double epoch=2000) const
 Convert to a specified Coord type at a specified epoch. 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 63 of file Coord.h.

Constructor & Destructor Documentation

◆ Coord() [1/7]

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 298 of file Coord.cc.

299  : _longitude(NaN), _latitude(NaN), _epoch(epoch) {
300  _longitude = geom::Angle(p2d.getX(), unit).wrap();
301  _latitude = geom::Angle(p2d.getY(), unit);
302  _verifyValues();
303 }
lsst::afw::geom::Angle Angle
Definition: misc.h:36
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
def wrap(ctrl)
Definition: wrap.py:250
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 <= x < 2PI.
Definition: Coord.cc:331

◆ Coord() [2/7]

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 305 of file Coord.cc.

306  : _longitude(0. * geom::radians), _latitude(0. * geom::radians), _epoch(epoch) {
307  std::pair<geom::Angle, geom::Angle> lonLat = pointToLonLat(p3d, defaultLongitude, normalize);
308  _longitude = lonLat.first;
309  _latitude = lonLat.second;
310  _epoch = epoch;
311 }
def normalize(v)
Definition: geometry.py:99
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278

◆ Coord() [3/7]

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 313 of file Coord.cc.

314  : _longitude(ra.wrap()), _latitude(dec), _epoch(epoch) {
315  _verifyValues();
316 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 <= x < 2PI.
Definition: Coord.cc:331

◆ Coord() [4/7]

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 318 of file Coord.cc.

320  _verifyValues();
321 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:284
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
def wrap(ctrl)
Definition: wrap.py:250
lsst::afw::geom::Angle hmsStringToAngle(std::string const hms)
Convert a hh:mm:ss string to Angle.
Definition: Coord.cc:282
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 <= x < 2PI.
Definition: Coord.cc:331

◆ Coord() [5/7]

lsst::afw::coord::Coord::Coord ( )

Default constructor for the Coord base class.

Sets all values to NaN

Definition at line 324 of file Coord.cc.

lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
A class representing an angle.
Definition: Angle.h:102

◆ ~Coord()

virtual lsst::afw::coord::Coord::~Coord ( )
virtualdefault

◆ Coord() [6/7]

lsst::afw::coord::Coord::Coord ( Coord const &  )
default

◆ Coord() [7/7]

lsst::afw::coord::Coord::Coord ( Coord &&  )
default

Member Function Documentation

◆ _verifyValues()

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 331 of file Coord.cc.

331  {
333  throw LSST_EXCEPT(
335  (boost::format("Latitude coord must be: -PI/2 <= lat <= PI/2 (%f).") % _latitude).str());
336  }
337 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
double constexpr HALFPI
Definition: Angle.h:23
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
constexpr double asRadians() const noexcept
Return an Angle&#39;s value in radians.
Definition: Angle.h:141

◆ angularSeparation()

geom::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 506 of file Coord.cc.

506  {
507  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
508  // we'll put them in the same system.
509  std::pair<Fk5Coord, Fk5Coord> const &fk5 = commonFk5(*this, c);
510  geom::Angle const alpha1 = fk5.first.getRa();
511  geom::Angle const delta1 = fk5.first.getDec();
512  geom::Angle const alpha2 = fk5.second.getRa();
513  geom::Angle const delta2 = fk5.second.getDec();
514 
515  return haversine(alpha1 - alpha2, delta1 - delta2, std::cos(delta1), std::cos(delta2));
516 }
A class representing an angle.
Definition: Angle.h:102
T cos(T... args)

◆ clone()

virtual std::shared_ptr<Coord> lsst::afw::coord::Coord::clone ( ) const
inlinevirtual

◆ convert()

std::shared_ptr< Coord > lsst::afw::coord::Coord::convert ( CoordSystem  system,
double  epoch = 2000 
) const

Convert to a specified Coord type at a specified epoch.

Parameters
[in]systemcoordinate system to which to convert
[in]epochepoch of coordinate system; only relevant for FK5 and Ecliptic coordinates
Exceptions
lsst::pex::exceptions::InvalidParameterErrorif system = TOPOCENTRIC (because observatory data is required) or if system not recognized

Definition at line 471 of file Coord.cc.

471  {
472  switch (system) {
473  case FK5: {
474  Fk5Coord c1 = this->toFk5(epoch);
476  new Fk5Coord(c1.getLongitude(), c1.getLatitude(), c1.getEpoch()));
477  } break;
478  case ICRS: {
479  IcrsCoord c2 = this->toIcrs();
480  return std::shared_ptr<IcrsCoord>(new IcrsCoord(c2.getLongitude(), c2.getLatitude()));
481  } break;
482  case GALACTIC: {
483  GalacticCoord c4 = this->toGalactic();
484  return std::shared_ptr<GalacticCoord>(new GalacticCoord(c4.getLongitude(), c4.getLatitude()));
485  } break;
486  case ECLIPTIC: {
487  EclipticCoord c5 = this->toEcliptic(epoch);
489  new EclipticCoord(c5.getLongitude(), c5.getLatitude(), c5.getEpoch()));
490  } break;
491  case TOPOCENTRIC:
493  "Cannot make Topocentric with convert() (must also specify Observatory).\n"
494  "Instantiate TopocentricCoord() directly.");
495  break;
496  case UNKNOWN:
497  throw LSST_EXCEPT(ex::InvalidParameterError, "Cannot convert to UNKNOWN coordinate system");
498  break;
499  default:
501  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC allowed.");
502  break;
503  }
504 }
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:572
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:574
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:35
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use existing epoch)
Definition: Coord.cc:577

◆ getClassName()

virtual std::string lsst::afw::coord::Coord::getClassName ( ) const
inlinevirtual

◆ getCoordNames()

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 143 of file Coord.h.

143  {
144  return std::pair<std::string, std::string>("RA", "Dec");
145  }

◆ getCoordSystem()

virtual CoordSystem lsst::afw::coord::Coord::getCoordSystem ( ) const
inlinevirtual

◆ getEpoch()

double lsst::afw::coord::Coord::getEpoch ( ) const
inline

Definition at line 131 of file Coord.h.

131 { return _epoch; }

◆ getLatitude()

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 173 of file Coord.h.

173 { return _latitude; };
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279

◆ getLatitudeStr()

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 840 of file Coord.h.

840 { return angleToDmsString(getLatitude()); }
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
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:249

◆ getLongitude()

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 166 of file Coord.h.

166 { return _longitude; };
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278

◆ getLongitudeStr()

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 824 of file Coord.h.

824  {
825  if (unit == lsst::afw::geom::hours) {
826  return angleToHmsString(getLongitude());
827  } else if (unit == lsst::afw::geom::degrees) {
828  return angleToDmsString(getLongitude());
829  } else {
830  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError, "Units must be 'degrees' or 'hours'");
831  }
832 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
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:249
AngleUnit constexpr hours
constant with units of hours
Definition: Angle.h:89
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:251
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ getOffsetFrom()

std::pair< geom::Angle, geom::Angle > lsst::afw::coord::Coord::getOffsetFrom ( Coord const &  c) const

Compute the offset from a coordinate.

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

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

Definition at line 518 of file Coord.cc.

518  {
519  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
520  // we'll put them in the same system.
521  std::pair<Fk5Coord, Fk5Coord> const &fk5 = commonFk5(*this, c);
522  geom::Angle const alpha1 = fk5.first.getRa();
523  geom::Angle const delta1 = fk5.first.getDec();
524  geom::Angle const alpha2 = fk5.second.getRa();
525  geom::Angle const delta2 = fk5.second.getDec();
526 
527  geom::Angle const dAlpha = alpha1 - alpha2;
528  geom::Angle const dDelta = delta1 - delta2;
529 
530  double const cosDelta1 = std::cos(delta1);
531  double const cosDelta2 = std::cos(delta2);
532 
533  geom::Angle separation = haversine(dAlpha, dDelta, cosDelta1, cosDelta2);
534 
535  // Formula from http://www.movable-type.co.uk/scripts/latlong.html
536  double const y = std::sin(dAlpha) * cosDelta2;
537  double const x = cosDelta1 * std::sin(delta2) - std::sin(delta1) * cosDelta2 * std::cos(dAlpha);
538  geom::Angle bearing = std::atan2(y, x) * geom::radians - 90.0 * geom::degrees;
539 
540  return std::make_pair(bearing, separation);
541 }
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
T atan2(T... args)
T sin(T... args)
A class representing an angle.
Definition: Angle.h:102
T make_pair(T... args)
T cos(T... args)
double x

◆ getPosition()

geom::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 346 of file Coord.cc.

346  {
347  // treat HOURS specially, they must mean hours for RA, degrees for Dec
348  if (unit == geom::hours) {
349  return geom::Point2D(getLongitude().asHours(), getLatitude().asDegrees());
350  } else {
351  return geom::Point2D(getLongitude().asAngularUnits(unit), getLatitude().asAngularUnits(unit));
352  }
353 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
Point< double, 2 > Point2D
Definition: Point.h:300
AngleUnit constexpr hours
constant with units of hours
Definition: Angle.h:89

◆ getTangentPlaneOffset()

std::pair< geom::Angle, geom::Angle > lsst::afw::coord::Coord::getTangentPlaneOffset ( Coord const &  c) const

Get the offset on the tangent plane.

This is suitable only for small angles.

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

Definition at line 543 of file Coord.cc.

543  {
544  // work in Fk5, no matter what two derived classes we're given (eg Fk5 and Galactic)
545  // we'll put them in the same system.
546  std::pair<Fk5Coord, Fk5Coord> const &fk5 = commonFk5(*this, c);
547  geom::Angle const alpha1 = fk5.first.getRa();
548  geom::Angle const delta1 = fk5.first.getDec();
549  geom::Angle const alpha2 = fk5.second.getRa();
550  geom::Angle const delta2 = fk5.second.getDec();
551 
552  // This is a projection of coord2 to the tangent plane at coord1
553  double const sinDelta1 = std::sin(delta1);
554  double const cosDelta1 = std::cos(delta1);
555  double const sinDelta2 = std::sin(delta2);
556  double const cosDelta2 = std::cos(delta2);
557  double const cosAlphaDiff = std::cos(alpha2 - alpha1);
558  double const sinAlphaDiff = std::sin(alpha2 - alpha1);
559 
560  double const div = cosDelta1 * cosAlphaDiff * cosDelta2 + sinDelta1 * sinDelta2;
561  double const xi = cosDelta1 * sinAlphaDiff / div;
562  double const eta = (cosDelta1 * cosAlphaDiff * sinDelta2 - sinDelta1 * cosDelta2) / div;
563 
564  return std::make_pair(xi * geom::radians, eta * geom::radians);
565 }
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
T sin(T... args)
A class representing an angle.
Definition: Angle.h:102
T make_pair(T... args)
T cos(T... args)
T div(T... args)

◆ getVector()

geom::Point3D lsst::afw::coord::Coord::getVector ( ) const

Return our contents in a position vector.

Definition at line 355 of file Coord.cc.

355  {
356  double lng = getLongitude();
357  double lat = getLatitude();
358  double const x = std::cos(lng) * std::cos(lat);
359  double const y = std::sin(lng) * std::cos(lat);
360  double const z = std::sin(lat);
361  return geom::Point3D(x, y, z);
362 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
T sin(T... args)
T cos(T... args)
double x
Point< double, 3 > Point3D
Definition: Point.h:301

◆ offset()

geom::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

Parameters
phiangle wrt parallel to offset
arcLenangle to offset
Returns
the angle wrt a declination parallel at new position
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

Definition at line 409 of file Coord.cc.

409  {
410  // let v = vector in the direction arcLen points (tangent to surface of sphere)
411  // thus: |v| = arcLen
412  // angle phi = orientation of v in a tangent plane, measured wrt to a parallel of declination
413 
414  // To do the rotation, use rotate() method.
415  // - must provide an axis of rotation: take the cross product r x v to get that axis (pole)
416 
417  // get the vector r
418  Eigen::Vector3d r = getVector().asEigen();
419 
420  // Get the vector v:
421  // let u = unit vector lying on a parallel of declination
422  // let w = unit vector along line of longitude = r x u
423  // the vector v must satisfy the following:
424  // |v| = arcLen
425  // r . v = 0
426  // u . v = |v| cos(phi) = arcLen*cos(phi)
427  // w . v = |v| sin(phi) = arcLen*sin(phi)
428 
429  // v is a linear combination of u and w
430  // v = arcLen*cos(phi)*u + arcLen*sin(phi)*w
431 
432  // Thus, we must:
433  // - create u vector
434  // - solve w vector (r cross u)
435  // - compute v
436  Eigen::Vector3d u;
437  u << -std::sin(getLongitude()), std::cos(getLongitude()), 0.0;
438  Eigen::Vector3d w = r.cross(u);
439  Eigen::Vector3d v = arcLen * std::cos(phi) * u + arcLen * std::sin(phi) * w;
440 
441  // take r x v to get the axis
442  Eigen::Vector3d axisVector = r.cross(v);
443  axisVector.normalize();
444  Coord axisCoord = Coord(geom::Point3D(axisVector), getEpoch());
445 
446  rotate(axisCoord, arcLen);
447 
448  // now get the position angle at our destination
449  // u2 . v2 = arcLen*cos(phi2)
450  // w2 . v2 = arcLen*sin(phi2)
451  // if we normalize v2:
452  // phi2 = atan2(w2.v2, u2.v2)
453  //
454  // we need to compute u2, and then rotate v (exactly as we rotated r) to get v2
455  Eigen::Vector3d r2 = getVector().asEigen();
456  Eigen::Vector3d u2;
457  u2 << -std::sin(getLongitude()), std::cos(getLongitude()), 0.0;
458  Eigen::Vector3d w2 = r2.cross(u2);
459 
460  // make v a unit vector and rotate v exactly as we rotated r
461  v.normalize();
462  Coord v2Coord = Coord(geom::Point3D(v), getEpoch());
463  v2Coord.rotate(axisCoord, arcLen);
464  Eigen::Vector3d v2 = v2Coord.getVector().asEigen();
465 
466  geom::Angle phi2 = std::atan2(w2.dot(v2), u2.dot(v2)) * geom::radians;
467 
468  return phi2;
469 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
A coordinate class intended to represent absolute positions.
T atan2(T... args)
T sin(T... args)
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
A class representing an angle.
Definition: Angle.h:102
void rotate(Coord const &axis, lsst::afw::geom::Angle const theta)
Rotate our current coords about a pole.
Definition: Coord.cc:382
double w
Definition: CoaddPsf.cc:57
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:355
T cos(T... args)
double getEpoch() const
Definition: Coord.h:131
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:324

◆ operator=() [1/2]

Coord & lsst::afw::coord::Coord::operator= ( Coord const &  )
default

◆ operator=() [2/2]

Coord & lsst::afw::coord::Coord::operator= ( Coord &&  )
default

◆ operator==()

bool lsst::afw::coord::Coord::operator== ( Coord const &  rhs) const
inline

Equality operator, compares each element directly.

Definition at line 845 of file Coord.h.

845  {
846  return (_longitude == rhs._longitude) && (_latitude == rhs._latitude) && (_epoch == rhs._epoch);
847 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278

◆ operator[]()

geom::Angle lsst::afw::coord::Coord::operator[] ( int const  index) const
inline

Provide access to our contents via an index.

Definition at line 801 of file Coord.h.

801  {
802  switch (index) {
803  case 0:
804  return _longitude;
805  break;
806  case 1:
807  return _latitude;
808  break;
809  default:
810  throw LSST_EXCEPT(lsst::pex::exceptions::InvalidParameterError, "Index must be 0 or 1.");
811  break;
812  }
813 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ reset() [1/2]

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 115 of file Coord.h.

115  {
116  double const epoch = 2000.0;
117  reset(longitude, latitude, epoch);
118  }
table::Key< geom::Angle > latitude
Definition: VisitInfo.cc:165
table::Key< geom::Angle > longitude
Definition: VisitInfo.cc:166
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
Definition: Coord.h:115

◆ reset() [2/2]

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 339 of file Coord.cc.

339  {
340  _longitude = longitude.wrap();
342  _epoch = epoch;
343  _verifyValues();
344 }
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
table::Key< geom::Angle > latitude
Definition: VisitInfo.cc:165
table::Key< geom::Angle > longitude
Definition: VisitInfo.cc:166
void _verifyValues() const
Make sure the values we&#39;ve got are in the range 0 <= x < 2PI.
Definition: Coord.cc:331

◆ rotate()

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 382 of file Coord.cc.

382  {
383  double const c = std::cos(theta);
384  double const mc = 1.0 - c;
385  double const s = std::sin(theta);
386 
387  // convert to cartesian
388  geom::Point3D const x = getVector();
389  geom::Point3D const u = axis.getVector();
390  double const ux = u[0];
391  double const uy = u[1];
392  double const uz = u[2];
393 
394  // rotate
395  geom::Point3D xprime;
396  xprime[0] = (ux * ux + (1.0 - ux * ux) * c) * x[0] + (ux * uy * mc - uz * s) * x[1] +
397  (ux * uz * mc + uy * s) * x[2];
398  xprime[1] = (uy * uy + (1.0 - uy * uy) * c) * x[1] + (uy * uz * mc - ux * s) * x[2] +
399  (ux * uy * mc + uz * s) * x[0];
400  xprime[2] = (uz * uz + (1.0 - uz * uz) * c) * x[2] + (uz * ux * mc - uy * s) * x[0] +
401  (uy * uz * mc + ux * s) * x[1];
402 
403  // in-situ
404  std::pair<geom::Angle, geom::Angle> lonLat = pointToLonLat(xprime);
405  _longitude = lonLat.first;
406  _latitude = lonLat.second;
407 }
solver_t * s
lsst::afw::geom::Angle _latitude
Definition: Coord.h:279
lsst::afw::geom::Angle _longitude
Definition: Coord.h:278
A coordinate class intended to represent absolute positions.
T sin(T... args)
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:355
T cos(T... args)
double x

◆ toEcliptic() [1/2]

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 576 of file Coord.cc.

576 { return this->toFk5(epoch).toEcliptic(); }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570
virtual EclipticCoord toEcliptic(double const epoch) const
Convert ourself to Ecliptic: lambda, beta (precess to new epoch)
Definition: Coord.cc:618

◆ toEcliptic() [2/2]

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 577 of file Coord.cc.

577 { return this->toFk5().toEcliptic(); }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570
virtual EclipticCoord toEcliptic(double const epoch) const
Convert ourself to Ecliptic: lambda, beta (precess to new epoch)
Definition: Coord.cc:618

◆ toFk5() [1/2]

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 567 of file Coord.cc.

567  {
568  return Fk5Coord(getLongitude(), getLatitude(), getEpoch()).precess(epoch);
569 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
double getEpoch() const
Definition: Coord.h:131

◆ toFk5() [2/2]

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 570 of file Coord.cc.

570 { return Fk5Coord(getLongitude(), getLatitude(), getEpoch()); }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
double getEpoch() const
Definition: Coord.h:131

◆ toGalactic()

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 574 of file Coord.cc.

574 { return this->toFk5().toGalactic(); }
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:605
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570

◆ toIcrs()

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 572 of file Coord.cc.

572 { return this->toFk5().toIcrs(); }
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:595

◆ toString()

std::string lsst::afw::coord::Coord::toString ( ) const
virtual

Get string representation.

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

Definition at line 967 of file Coord.cc.

967  {
968  return (boost::format("%s(%.7f, %.7f, %.2f)") % getClassName() % (*this)[0].asDegrees() %
969  (*this)[1].asDegrees() % getEpoch())
970  .str();
971 }
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:134
double getEpoch() const
Definition: Coord.h:131
virtual std::string getClassName() const
Definition: Coord.h:147

◆ toTopocentric()

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 579 of file Coord.cc.

580  {
581  return this->toFk5().toTopocentric(obs, obsDate);
582 }
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
Definition: Coord.cc:627
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570

◆ transform()

Coord lsst::afw::coord::Coord::transform ( Coord const &  poleTo,
Coord const &  poleFrom 
) const

Transform our current coords to another spherical polar system.

Variable names assume an equatorial/galactic transform, 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 364 of file Coord.cc.

364  {
365  double const alphaGP = poleFrom[0];
366  double const deltaGP = poleFrom[1];
367  double const lCP = poleTo[0];
368 
369  double const alpha = getLongitude();
370  double const delta = getLatitude();
371 
372  geom::Angle const l = (lCP - std::atan2(std::sin(alpha - alphaGP),
373  std::tan(delta) * std::cos(deltaGP) -
374  std::cos(alpha - alphaGP) * std::sin(deltaGP))) *
376  geom::Angle const b = std::asin((std::sin(deltaGP) * std::sin(delta) +
377  std::cos(deltaGP) * std::cos(delta) * std::cos(alpha - alphaGP))) *
379  return Coord(l, b);
380 }
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
T atan2(T... args)
T sin(T... args)
A class representing an angle.
Definition: Angle.h:102
table::Key< int > b
T cos(T... args)
T asin(T... args)
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:324
T tan(T... args)
def alpha(r, centerPhi, phi)
Definition: geometry.py:222

Member Data Documentation

◆ _epoch

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

Definition at line 280 of file Coord.h.

◆ _latitude

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

Definition at line 279 of file Coord.h.

◆ _longitude

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

Definition at line 278 of file Coord.h.


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