lsst.afw  14.0-42-g99f9a3040+1
Coord.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
25 /*
26  * Provide functions to handle coordinates
27  *
28  * Most (nearly all) algorithms adapted from Astronomical Algorithms, 2nd ed. (J. Meeus)
29  *
30  */
31 #include <cmath>
32 #include <limits>
33 #include <cstdio>
34 #include <iomanip>
35 
36 #include "Eigen/Core"
37 #include "Eigen/Geometry"
38 
39 #include "lsst/pex/exceptions.h"
40 #include "boost/algorithm/string.hpp"
41 #include "boost/tuple/tuple.hpp"
42 #include "boost/format.hpp"
43 
44 #include "lsst/afw/coord/Coord.h"
45 #include "lsst/daf/base/DateTime.h"
46 
47 namespace ex = lsst::pex::exceptions;
48 namespace dafBase = lsst::daf::base;
49 
50 namespace lsst {
51 namespace afw {
52 namespace coord {
53 
54 namespace {
55 
56 typedef std::map<std::string, CoordSystem> CoordSystemMap;
57 
58 CoordSystemMap const getCoordSystemMap() {
59  CoordSystemMap idMap;
60  idMap["FK5"] = FK5;
61  idMap["ICRS"] = ICRS;
62  idMap["ECLIPTIC"] = ECLIPTIC;
63  idMap["GALACTIC"] = GALACTIC;
64  idMap["ELON"] = ECLIPTIC;
65  idMap["GLON"] = GALACTIC;
66  idMap["TOPOCENTRIC"] = TOPOCENTRIC;
67  return idMap;
68 }
69 
80 geom::Angle haversine(geom::Angle const dAlpha, geom::Angle const dDelta, double const cosDelta1,
81  double const cosDelta2) {
82  double const havDDelta = std::sin(dDelta / 2.0) * std::sin(dDelta / 2.0);
83  double const havDAlpha = std::sin(dAlpha / 2.0) * std::sin(dAlpha / 2.0);
84  double const havD = havDDelta + cosDelta1 * cosDelta2 * havDAlpha;
85  double const sinDHalf = std::sqrt(havD);
86  geom::Angle dist = (2.0 * std::asin(sinDHalf)) * geom::radians;
87  return dist;
88 }
89 
91 double const epochTolerance = 1.0e-12;
92 
94 std::pair<Fk5Coord, Fk5Coord> commonFk5(Coord const &c1, Coord const &c2) {
95  // make sure they're fk5
96  Fk5Coord fk51 = c1.toFk5();
97  Fk5Coord fk5tmp = c2.toFk5();
98 
99  // make sure they have the same epoch
100  Fk5Coord fk52;
101  if (fabs(fk51.getEpoch() - fk5tmp.getEpoch()) > epochTolerance) {
102  fk52 = fk5tmp.precess(fk51.getEpoch());
103  } else {
104  fk52 = fk5tmp;
105  }
106 
107  return std::make_pair(fk51, fk52);
108 }
109 
110 } // end anonymous namespace
111 
113  static CoordSystemMap idmap = getCoordSystemMap();
114  if (idmap.find(system) != idmap.end()) {
115  return idmap[system];
116  } else {
117  throw LSST_EXCEPT(ex::InvalidParameterError, "System " + system + " not defined.");
118  }
119 }
120 
121 namespace {
122 
123 double const NaN = std::numeric_limits<double>::quiet_NaN();
124 double const JD2000 = 2451544.50;
125 
126 /*
127  * A local class to handle dd:mm:ss coordinates
128  *
129  * This class allows a decimal or dd:mm:ss coordinate to be
130  * disassembed into d, m, and s components.
131  * It's in an anonymous namespace, but there are public functions
132  * which perform the transformations directly:
133  *
134  * --> std::string dmsStr = degreesToDmsString(double deg);
135  * --> double deg = dmsStringToDegrees(std::string dms);
136  */
137 class Dms {
138 public:
139  Dms(){};
140 
141  // note that isSouth is needed to specify coords between dec = 0, and dec = -1
142  // otherwise, d = -0 gets carried as d = 0 ... need a way to specify it explicitly
143  Dms(int const d, int const m, double const s, bool const isSouth = false) {
144  sign = (d < 0 || isSouth) ? -1 : 1;
145  deg = std::abs(d);
146  min = m;
147  sec = s;
148  };
149  // unit could be "degrees" or "hours"
150  Dms(geom::Angle const deg00, geom::AngleUnit const unit = geom::degrees) {
151  double deg0 = deg00.asAngularUnits(unit);
152  double const absVal = std::fabs(deg0);
153  sign = (deg0 >= 0) ? 1 : -1;
154  deg = static_cast<int>(std::floor(absVal));
155  min = static_cast<int>(std::floor((absVal - deg) * 60.0));
156  sec = ((absVal - deg) * 60.0 - min) * 60.0;
157  }
158 
159  int deg;
160  int min;
161  double sec;
162  int sign;
163 };
164 
169 Coord const &GalacticPoleInFk5() {
170  static Coord pole(192.85950 * geom::degrees, 27.12825 * geom::degrees, 2000.0); // C&O
171  return pole;
172 }
173 
174 Coord const &Fk5PoleInGalactic() {
175  static Coord pole(122.93200 * geom::degrees, 27.12825 * geom::degrees, 2000.0); // C&O
176  return pole;
177 }
178 
183 geom::Angle meanSiderealTimeGreenwich(double const jd
184  ) {
185  double const T = (jd - 2451545.0) / 36525.0;
186  return (280.46061837 + 360.98564736629 * (jd - 2451545.0) + 0.000387933 * T * T -
187  (T * T * T / 38710000.0)) *
189 }
190 
191 double const atPoleEpsilon = 0.0; // std::numeric_limits<double>::epsilon();
192 std::pair<geom::Angle, geom::Angle> pointToLonLat(geom::Point3D const &p3d,
193  double const defaultLongitude = 0.0,
194  bool normalize = true) {
196 
197  if (normalize) {
198  double const inorm = 1.0 / p3d.asEigen().norm();
199  double const x = inorm * p3d.getX();
200  double const y = inorm * p3d.getY();
201  double const z = inorm * p3d.getZ();
202  if (fabs(x) <= atPoleEpsilon && fabs(y) <= atPoleEpsilon) {
203  lonLat.first = 0.0 * geom::radians;
204  lonLat.second = ((z >= 0) ? 1.0 : -1.0) * geom::HALFPI * geom::radians;
205  } else {
206  lonLat.first = (atan2(y, x) * geom::radians).wrap();
207  lonLat.second = asin(z) * geom::radians;
208  }
209  } else {
210  if (fabs(p3d.getX()) <= atPoleEpsilon && fabs(p3d.getY()) <= atPoleEpsilon) {
211  lonLat.first = 0.0 * geom::radians;
212  lonLat.second = ((p3d.getZ() >= 0) ? 1.0 : -1.0) * geom::HALFPI * geom::radians;
213  } else {
214  lonLat.first = (atan2(p3d.getY(), p3d.getX()) * geom::radians).wrap();
215  lonLat.second = asin(p3d.getZ()) * geom::radians;
216  }
217  }
218  return lonLat;
219 }
220 
221 } // end anonymous namespace
222 
223 /* ******************* Public functions ******************* */
224 
225 static std::string angleToXmsString(geom::Angle const a, geom::AngleUnit const unit) {
226  Dms dms(a, unit);
227 
228  // make sure rounding won't give 60.00 for sec or min
229  if ((60.00 - dms.sec) < 0.005) {
230  dms.sec = 0.0;
231  dms.min += 1;
232  if (dms.min == 60) {
233  dms.min = 0;
234  dms.deg += 1;
235  if (dms.deg == 360) {
236  dms.deg = 0;
237  }
238  }
239  }
240 
241  std::string fmt("%02d:%02d:%05.2f");
242  std::string s = (boost::format(fmt) % dms.deg % dms.min % dms.sec).str();
243  if (dms.sign < 0) {
244  s = "-" + s;
245  }
246  return s;
247 }
248 
249 std::string angleToDmsString(geom::Angle const a) { return angleToXmsString(a, geom::degrees); }
250 
251 std::string angleToHmsString(geom::Angle const a) { return angleToXmsString(a, geom::hours); }
252 
260 static geom::Angle xmsStringToAngle(std::string const dms, geom::AngleUnit unit) {
261  if (dms.find(":") == std::string::npos) {
263  (boost::format("String is not in xx:mm:ss format: %s") % dms).str());
264  }
265  std::vector<std::string> elements;
266  boost::split(elements, dms, boost::is_any_of(":"));
267  if (elements.size() != 3) {
269  (boost::format("Could not parse string as xx:mm:ss format: %s") % dms).str());
270  }
271  int const deg = abs(atoi(elements[0].c_str()));
272  int const min = atoi(elements[1].c_str());
273  double const sec = atof(elements[2].c_str());
274 
275  geom::Angle ang = (deg + min / 60.0 + sec / 3600.0) * unit;
276  if ((elements[0].c_str())[0] == '-') {
277  ang *= -1.0;
278  }
279  return ang;
280 }
281 
282 geom::Angle hmsStringToAngle(std::string const hms) { return xmsStringToAngle(hms, geom::hours); }
283 
284 geom::Angle dmsStringToAngle(std::string const dms) { return xmsStringToAngle(dms, geom::degrees); }
285 
287  double const T = (epoch - 2000.0) / 100.0;
288  return (23.0 + 26.0 / 60.0 + (21.448 - 46.82 * T - 0.0006 * T * T - 0.0018 * T * T * T) / 3600.0) *
290 }
291 
292 /* ============================================================
293  *
294  * class Coord
295  *
296  * ============================================================*/
297 
298 Coord::Coord(geom::Point2D const &p2d, geom::AngleUnit unit, double const epoch)
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 }
304 
305 Coord::Coord(geom::Point3D const &p3d, double const epoch, bool normalize, geom::Angle const defaultLongitude)
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 }
312 
313 Coord::Coord(geom::Angle const ra, geom::Angle const dec, double const epoch)
314  : _longitude(ra.wrap()), _latitude(dec), _epoch(epoch) {
315  _verifyValues();
316 }
317 
318 Coord::Coord(std::string const ra, std::string const dec, double const epoch)
319  : _longitude(hmsStringToAngle(ra).wrap()), _latitude(dmsStringToAngle(dec)), _epoch(epoch) {
320  _verifyValues();
321 }
322 
323 // Don't call _verifyValues() method ... it'll fail
324 Coord::Coord() : _longitude(geom::Angle(NaN)), _latitude(geom::Angle(NaN)), _epoch(NaN) {}
325 
326 Coord::Coord(Coord const &) = default;
327 Coord::Coord(Coord &&) = default;
328 Coord &Coord::operator=(Coord const &) = default;
329 Coord &Coord::operator=(Coord &&) = default;
330 
331 void Coord::_verifyValues() const {
332  if (_latitude.asRadians() < -geom::HALFPI || _latitude.asRadians() > geom::HALFPI) {
333  throw LSST_EXCEPT(
335  (boost::format("Latitude coord must be: -PI/2 <= lat <= PI/2 (%f).") % _latitude).str());
336  }
337 }
338 
339 void Coord::reset(geom::Angle const longitude, geom::Angle const latitude, double const epoch) {
340  _longitude = longitude.wrap();
341  _latitude = latitude;
342  _epoch = epoch;
343  _verifyValues();
344 }
345 
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 }
354 
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 }
363 
364 Coord Coord::transform(Coord const &poleTo, Coord const &poleFrom) const {
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 }
381 
382 void Coord::rotate(Coord const &axis, geom::Angle const theta) {
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 }
408 
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 }
470 
471 std::shared_ptr<Coord> Coord::convert(CoordSystem system, double epoch) const {
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();
481  } break;
482  case GALACTIC: {
483  GalacticCoord c4 = this->toGalactic();
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 }
505 
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 }
517 
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 }
542 
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 }
566 
567 Fk5Coord Coord::toFk5(double const epoch) const {
568  return Fk5Coord(getLongitude(), getLatitude(), getEpoch()).precess(epoch);
569 }
571 
572 IcrsCoord Coord::toIcrs() const { return this->toFk5().toIcrs(); }
573 
574 GalacticCoord Coord::toGalactic() const { return this->toFk5().toGalactic(); }
575 
576 EclipticCoord Coord::toEcliptic(double const epoch) const { return this->toFk5(epoch).toEcliptic(); }
577 EclipticCoord Coord::toEcliptic() const { return this->toFk5().toEcliptic(); }
578 
580  lsst::daf::base::DateTime const &obsDate) const {
581  return this->toFk5().toTopocentric(obs, obsDate);
582 }
583 
584 /* ============================================================
585  *
586  * class Fk5Coord
587  *
588  * ============================================================*/
589 
590 Fk5Coord Fk5Coord::toFk5(double const epoch) const {
591  return Fk5Coord(getLongitude(), getLatitude(), getEpoch()).precess(epoch);
592 }
594 
596  // only do the precession to 2000 if we're not already there.
597  if (fabs(getEpoch() - 2000.0) > epochTolerance) {
598  Fk5Coord c = precess(2000.0);
599  return IcrsCoord(c.getLongitude(), c.getLatitude());
600  } else {
601  return IcrsCoord(getLongitude(), getLatitude());
602  }
603 }
604 
606  // if we're epoch==2000, we can transform, otherwise we need to precess first
607  Fk5Coord c;
608  if (fabs(getEpoch() - 2000.0) > epochTolerance) {
609  c = precess(2000.0);
610  } else {
611  c = *this;
612  }
613 
614  Coord ct = c.transform(Fk5PoleInGalactic(), GalacticPoleInFk5());
615  return GalacticCoord(ct.getLongitude(), ct.getLatitude());
616 }
617 
618 EclipticCoord Fk5Coord::toEcliptic(double const epoch) const {
619  geom::Angle const eclPoleIncl = eclipticPoleInclination(epoch);
620  Coord const eclPoleInEquatorial(270.0 * geom::degrees, (90.0 * geom::degrees) - eclPoleIncl, epoch);
621  Coord const equPoleInEcliptic(90.0 * geom::degrees, (90.0 * geom::degrees) - eclPoleIncl, epoch);
622  Coord c = transform(equPoleInEcliptic, eclPoleInEquatorial);
623  return EclipticCoord(c.getLongitude(), c.getLatitude(), epoch);
624 }
626 
628  lsst::daf::base::DateTime const &obsDate) const {
629  // make sure we precess to the epoch
630  Fk5Coord fk5 = precess(obsDate.get(dafBase::DateTime::EPOCH));
631 
632  // greenwich sidereal time
633  geom::Angle theta0 = meanSiderealTimeGreenwich(obsDate.get(dafBase::DateTime::JD)).wrap();
634 
635  // lat/long of the observatory
636  geom::Angle const phi = obs.getLatitude();
637  geom::Angle const L = obs.getLongitude();
638 
639  // ra/dec of the target
640  geom::Angle const alpha = fk5.getRa();
641  geom::Angle const delta = fk5.getDec();
642 
643  geom::Angle const H = theta0 + L - alpha;
644 
645  // compute the altitude, h
646  double const sinh = std::sin(phi) * std::sin(delta) + std::cos(phi) * std::cos(delta) * std::cos(H);
647  geom::Angle const h = std::asin(sinh) * geom::radians;
648 
649  // compute the azimuth, A
650  double const tanAnumerator = std::sin(H);
651  double const tanAdenominator = (std::cos(H) * std::sin(phi) - std::tan(delta) * std::cos(phi));
652 
653  // Equations used here assume azimuth is with respect to South
654  // but we use the North as our origin ... must add 180 deg
655  geom::Angle A = ((180.0 * geom::degrees) + atan2(tanAnumerator, tanAdenominator) * geom::radians).wrap();
656 
657  return TopocentricCoord(A, h, obsDate.get(dafBase::DateTime::EPOCH), obs);
658 }
659 
660 Fk5Coord Fk5Coord::precess(double const epochTo) const {
661  // return a copy if the epochs are the same
662  if (fabs(getEpoch() - epochTo) < epochTolerance) {
663  return Fk5Coord(getLongitude(), getLatitude(), getEpoch());
664  }
665 
668  double const jd0 = dateFrom.get(dafBase::DateTime::JD);
669  double const jd = dateTo.get(dafBase::DateTime::JD);
670 
671  double const T = (jd0 - JD2000) / 36525.0;
672  double const t = (jd - jd0) / 36525.0;
673  double const tt = t * t;
674  double const ttt = tt * t;
675 
676  geom::Angle const xi = ((2306.2181 + 1.39656 * T - 0.000139 * T * T) * t + (0.30188 - 0.000344 * T) * tt +
677  0.017998 * ttt) *
679  geom::Angle const z = ((2306.2181 + 1.39656 * T - 0.000139 * T * T) * t + (1.09468 + 0.000066 * T) * tt +
680  0.018203 * ttt) *
682  geom::Angle const theta = ((2004.3109 - 0.85330 * T - 0.000217 * T * T) * t -
683  (0.42665 + 0.000217 * T) * tt - 0.041833 * ttt) *
685 
686  Fk5Coord fk5 = this->toFk5();
687  geom::Angle const alpha0 = fk5.getRa();
688  geom::Angle const delta0 = fk5.getDec();
689 
690  double const a = std::cos(delta0) * std::sin((alpha0 + xi));
691  double const b =
692  std::cos(theta) * std::cos(delta0) * std::cos((alpha0 + xi)) - std::sin(theta) * std::sin(delta0);
693  double const c =
694  std::sin(theta) * std::cos(delta0) * std::cos((alpha0 + xi)) + std::cos(theta) * std::sin(delta0);
695 
696  geom::Angle const alpha = (std::atan2(a, b) + z) * geom::radians;
697  geom::Angle const delta = std::asin(c) * geom::radians;
698 
699  return Fk5Coord(alpha, delta, epochTo);
700 }
701 
702 /* ============================================================
703  *
704  * class IcrsCoord
705  *
706  * ============================================================*/
707 
709  Coord::reset(longitude, latitude, 2000.0);
710 }
711 
712 Fk5Coord IcrsCoord::toFk5(double const epoch) const {
713  return Fk5Coord(getLongitude(), getLatitude(), 2000.0).precess(epoch);
714 }
715 Fk5Coord IcrsCoord::toFk5() const { return Fk5Coord(getLongitude(), getLatitude(), 2000.0); }
716 
718 
720  return (boost::format("%s(%.7f, %.7f)") % getClassName() % (*this)[0].asDegrees() %
721  (*this)[1].asDegrees())
722  .str();
723 }
724 
725 /* ============================================================
726  *
727  * class GalacticCoord
728  *
729  * ============================================================*/
730 
731 void GalacticCoord::reset(geom::Angle const longitudeDeg, geom::Angle const latitudeDeg) {
732  Coord::reset(longitudeDeg, latitudeDeg, 2000.0);
733 }
734 
735 Fk5Coord GalacticCoord::toFk5(double const epoch) const {
736  // transform to fk5
737  // galactic coords are ~constant, and the poles used are for epoch=2000, so we get J2000
738  Coord c = transform(GalacticPoleInFk5(), Fk5PoleInGalactic());
739  return Fk5Coord(c.getLongitude(), c.getLatitude(), 2000.0).precess(epoch);
740 }
741 Fk5Coord GalacticCoord::toFk5() const { return this->toFk5(2000.0); }
742 
744 
746  return (boost::format("%s(%.7f, %.7f)") % getClassName() % (*this)[0].asDegrees() %
747  (*this)[1].asDegrees())
748  .str();
749 }
750 
751 /* ============================================================
752  *
753  * class EclipticCoord
754  *
755  * ============================================================*/
756 
757 EclipticCoord EclipticCoord::toEcliptic(double const epoch) const {
758  return EclipticCoord(getLongitude(), getLatitude(), getEpoch()).precess(epoch);
759 }
762 }
763 
764 Fk5Coord EclipticCoord::toFk5(double const epoch) const {
765  geom::Angle const eclPoleIncl = eclipticPoleInclination(epoch);
766  geom::Angle ninety = 90. * geom::degrees;
767  Coord const eclipticPoleInFk5(270.0 * geom::degrees, ninety - eclPoleIncl, epoch);
768  Coord const fk5PoleInEcliptic(ninety, ninety - eclPoleIncl, epoch);
769  Coord c = transform(eclipticPoleInFk5, fk5PoleInEcliptic);
770  return Fk5Coord(c.getLongitude(), c.getLatitude(), epoch);
771 }
772 Fk5Coord EclipticCoord::toFk5() const { return this->toFk5(getEpoch()); }
773 
774 EclipticCoord EclipticCoord::precess(double const epochTo) const {
775  return this->toFk5().precess(epochTo).toEcliptic();
776 }
777 
778 /* ============================================================
779  *
780  * class TopocentricCoord
781  *
782  * ============================================================*/
783 
784 Fk5Coord TopocentricCoord::toFk5(double const epoch) const {
785  geom::Angle const phi = _obs.getLatitude();
786  geom::Angle const L = _obs.getLongitude();
787 
788  // Equations used here assume azimuth is with respect to South
789  // but we use the North as our origin.
790  geom::Angle A = (getAzimuth() + 180.0 * geom::degrees).wrap();
791  geom::Angle const h = getAltitude();
792 
795  geom::Angle theta0 = meanSiderealTimeGreenwich(jd).wrap();
796 
797  double const tanHnum = std::sin(A);
798  double const tanHdenom = std::cos(A) * std::sin(phi) + std::tan(h) * std::cos(phi);
799  geom::Angle H = std::atan2(tanHnum, tanHdenom) * geom::radians;
800 
801  geom::Angle const alpha = theta0 + L - H;
802  double const sinDelta = std::sin(phi) * std::sin(h) - std::cos(phi) * std::cos(h) * std::cos(A);
803  geom::Angle const delta = (std::asin(sinDelta)) * geom::radians;
804 
805  return Fk5Coord(alpha, delta, epoch);
806 }
807 Fk5Coord TopocentricCoord::toFk5() const { return this->toFk5(getEpoch()); }
808 
810  lsst::daf::base::DateTime const &date) const {
811  if (obs != _obs) {
813  (boost::format("Expected observatory %s, saw %s") % _obs % obs).str());
814  }
815  if (fabs(date.get() - getEpoch()) > std::numeric_limits<double>::epsilon()) {
817  (boost::format("Expected date %g, saw %g") % getEpoch() % date.get()).str());
818  }
819 
820  return TopocentricCoord(getLongitude(), getLatitude(), getEpoch(), _obs);
821 }
822 
824  return TopocentricCoord(getLongitude(), getLatitude(), getEpoch(), _obs);
825 }
826 
828  return (boost::format("%s(%.7f, %.7f, %.12f, (%s))") % getClassName() % (*this)[0].asDegrees() %
829  (*this)[1].asDegrees() % getEpoch() % getObservatory())
830  .str();
831 }
832 
833 /* ===============================================================================
834  *
835  * Factory function definitions:
836  *
837  * Each makeCoord() function has overloaded variants with and without epoch specified.
838  * It was tempting to specify default values, but some coordinate systems have
839  * no epoch, and this would be confusing to the user. In its current form,
840  * any epochless coordinate system requested with an epoch specified will throw an exception.
841  * The epochless factories will always work, but assume default epoch = 2000.
842  *
843  * ===============================================================================
844  */
845 
847  double const epoch) {
848  switch (system) {
849  case FK5:
850  return std::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, epoch));
851  break;
852  case ICRS:
854  "ICRS has no epoch, use overloaded makeCoord with args (system, ra, dec).");
855  break;
856  case GALACTIC:
858  "Galactic has no epoch, use overloaded makeCoord with (system, ra, dec).");
859  break;
860  case ECLIPTIC:
861  return std::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, epoch));
862  break;
863  case TOPOCENTRIC:
865  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
866  "Instantiate TopocentricCoord() directly.");
867  break;
868  default:
869  throw LSST_EXCEPT(
871  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
872  break;
873  }
874 }
875 
877  switch (system) {
878  case FK5:
879  return std::shared_ptr<Fk5Coord>(new Fk5Coord(ra, dec, 2000.0));
880  break;
881  case ICRS:
882  return std::shared_ptr<IcrsCoord>(new IcrsCoord(ra, dec));
883  break;
884  case GALACTIC:
885  return std::shared_ptr<GalacticCoord>(new GalacticCoord(ra, dec));
886  break;
887  case ECLIPTIC:
888  return std::shared_ptr<EclipticCoord>(new EclipticCoord(ra, dec, 2000.0));
889  break;
890  case TOPOCENTRIC:
892  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
893  "Instantiate TopocentricCoord() directly.");
894  break;
895  default:
896  throw LSST_EXCEPT(
898  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, and TOPOCENTRIC allowed.");
899  break;
900  }
901 }
902 
903 std::shared_ptr<Coord> makeCoord(CoordSystem const system, geom::Point3D const &p3d, double const epoch,
904  bool normalize, geom::Angle const defaultLongitude) {
905  Coord c(p3d, 2000.0, normalize, defaultLongitude);
906  return makeCoord(system, c.getLongitude(), c.getLatitude(), epoch);
907 }
908 std::shared_ptr<Coord> makeCoord(CoordSystem const system, geom::Point3D const &p3d, bool normalize,
909  geom::Angle const defaultLongitude) {
910  Coord c(p3d, 2000.0, normalize, defaultLongitude);
911  return makeCoord(system, c.getLongitude(), c.getLatitude());
912 }
913 
915  double const epoch) {
916  if (unit == geom::hours) {
917  return makeCoord(system, geom::Angle(p2d.getX(), geom::hours), geom::Angle(p2d.getY(), geom::degrees),
918  epoch);
919  } else {
920  return makeCoord(system, geom::Angle(p2d.getX(), unit), geom::Angle(p2d.getY(), unit), epoch);
921  }
922 }
923 
925  if (unit == geom::hours) {
926  return makeCoord(system, geom::Angle(p2d.getX(), geom::hours),
927  geom::Angle(p2d.getY(), geom::degrees));
928  } else {
929  return makeCoord(system, geom::Angle(p2d.getX(), unit), geom::Angle(p2d.getY(), unit));
930  }
931 }
932 
934  double const epoch) {
935  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec), epoch);
936 }
938  return makeCoord(system, dmsStringToAngle(ra), dmsStringToAngle(dec));
939 }
940 
942  switch (system) {
943  case FK5:
944  return std::shared_ptr<Fk5Coord>(new Fk5Coord());
945  break;
946  case ICRS:
948  break;
949  case GALACTIC:
951  break;
952  case ECLIPTIC:
954  break;
955  case TOPOCENTRIC:
957  "Cannot make Topocentric with makeCoord() (must also specify Observatory).\n"
958  "Instantiate TopocentricCoord() directly.");
959  break;
960  default:
962  "Undefined CoordSystem: only FK5, ICRS, GALACTIC, ECLIPTIC, allowed.");
963  break;
964  }
965 }
966 
968  return (boost::format("%s(%.7f, %.7f, %.2f)") % getClassName() % (*this)[0].asDegrees() %
969  (*this)[1].asDegrees() % getEpoch())
970  .str();
971 }
972 
974  os << coord.toString();
975  return os;
976 }
977 
978 namespace {
979 
980 // Heavy lifting for averageCoord
982  CoordSystem system) {
983  assert(system != UNKNOWN); // Handled by caller
984  assert(coords.size() > 0); // Handled by caller
985  geom::Point3D sum(0, 0, 0);
986  geom::Point3D corr(0, 0, 0); // Kahan summation correction
987  for (auto &&cc : coords) {
988  geom::Point3D const point = cc->getVector();
989  // Kahan summation
990  geom::Extent3D const add = point - corr;
991  geom::Point3D const temp = sum + add;
992  corr = (temp - geom::Extent3D(sum)) - add;
993  sum = temp;
994  }
995  sum.scale(1.0 / coords.size());
996  return makeCoord(system, sum);
997 }
998 
999 } // anonymous namespace
1000 
1002  CoordSystem system) {
1003  if (coords.size() == 0) {
1004  throw LSST_EXCEPT(ex::LengthError, "No coordinates provided to average");
1005  }
1006 
1007  if (system == UNKNOWN) {
1008  // Determine which system we're using, and check that every coordinate is in that system
1009  system = coords[0]->getCoordSystem();
1010  for (auto &&cc : coords) {
1011  if (cc->getCoordSystem() != system) {
1013  (boost::format("Coordinates are not all in the same system: %d vs %d") %
1014  cc->getCoordSystem() %
1015  system).str());
1016  }
1017  }
1018  return doAverageCoord(coords, system);
1019  }
1020 
1021  // Convert everything to the nominated coordinate system if necessary
1023  converted.reserve(coords.size());
1024  for (auto &&cc : coords) {
1025  converted.push_back(cc->getCoordSystem() == system ? cc : cc->convert(system));
1026  }
1027  return doAverageCoord(converted, system);
1028 }
1029 }
1030 }
1031 } // end lsst::afw::coord
std::shared_ptr< Coord > makeCoord(CoordSystem const system, lsst::afw::geom::Angle const ra, lsst::afw::geom::Angle const dec, double const epoch)
Factory function to create a Coord of arbitrary type with decimal RA,Dec.
Definition: Coord.cc:846
lsst::afw::geom::Angle getLatitude() const
get telescope latitude
Definition: Observatory.cc:56
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
Definition: Coord.cc:627
lsst::afw::geom::Angle getLongitude() const
The main access method for the longitudinal coordinate.
Definition: Coord.h:166
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
special reset() overload to make sure no epoch can be set
Definition: Coord.cc:731
double get(DateSystem system=MJD, Timescale scale=TAI) const
lsst::afw::geom::Angle Angle
Definition: misc.h:36
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use current epoch)
Definition: Coord.cc:625
lsst::afw::coord::Coord Coord
Definition: misc.h:33
void scale(double factor)
Definition: Point.h:124
A class to handle Galactic coordinates (inherits from Coord)
Definition: Coord.h:426
lsst::afw::geom::Angle dmsStringToAngle(std::string const dms)
Convert a dd:mm:ss string to Angle.
Definition: Coord.cc:284
double constexpr HALFPI
Definition: Angle.h:23
virtual IcrsCoord toIcrs() const
Icrs converter for IcrsCoord.
Definition: Coord.cc:717
Hold the location of an observatory.
Definition: Observatory.h:41
AngleUnit constexpr radians
constant with units of radians
Definition: Angle.h:87
A coordinate class intended to represent offsets and dimensions.
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 ...
Definition: Coord.cc:409
EclipticCoord precess(double const epochTo) const
precess to new epoch
Definition: Coord.cc:774
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:88
lsst::afw::geom::Angle eclipticPoleInclination(double const epoch)
get the inclination of the ecliptic pole (obliquity) at epoch
Definition: Coord.cc:286
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
special reset() overload to make sure no epoch can be set
Definition: Coord.cc:708
int min
Definition: Coord.cc:160
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:572
std::pair< lsst::afw::geom::Angle, lsst::afw::geom::Angle > getTangentPlaneOffset(Coord const &c) const
Get the offset on the tangent plane.
Definition: Coord.cc:543
T floor(T... args)
virtual TopocentricCoord toTopocentric() const
Convert ourself from Topocentric to Topocentric with no observatory or date arguments.
Definition: Coord.cc:823
virtual Fk5Coord toFk5() const
Convert ourself from galactic to Fk5 (no epoch specified)
Definition: Coord.cc:741
Coord & operator=(Coord const &)
virtual Fk5Coord toFk5() const
Convert ourself to Fk5 (ie.
Definition: Coord.cc:593
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:574
table::Key< geom::Angle > latitude
Definition: VisitInfo.cc:165
STL class.
def wrap(ctrl)
A class used to convert scalar POD types such as double to Angle.
Definition: Angle.h:52
lsst::afw::geom::Angle getLatitude() const
The main access method for the latitudinal coordinate.
Definition: Coord.h:173
lsst::afw::geom::Point2D getPosition(lsst::afw::geom::AngleUnit unit=lsst::afw::geom::degrees) const
Return our contents in a Point2D object.
Definition: Coord.cc:346
std::ostream & operator<<(std::ostream &os, Coord const &coord)
Definition: Coord.cc:973
T atan2(T... args)
STL class.
lsst::afw::geom::Angle getDec() const
Definition: Coord.h:382
T sin(T... args)
virtual GalacticCoord toGalactic() const
Convert ourself to Galactic: l, b.
Definition: Coord.cc:605
T push_back(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
A class to handle topocentric (AltAz) coordinates (inherits from Coord)
Definition: Coord.h:562
void rotate(Coord const &axis, lsst::afw::geom::Angle const theta)
Rotate our current coords about a pole.
Definition: Coord.cc:382
Coord transform(Coord const &poleTo, Coord const &poleFrom) const
Transform our current coords to another spherical polar system.
Definition: Coord.cc:364
A base class for image defects.
virtual std::string toString() const
Get string representation.
Definition: Coord.cc:719
lsst::afw::geom::Angle getRa() const
Definition: Coord.h:381
Angle wrap() const noexcept
Wrap this angle to the range [0, 2π).
Definition: Angle.h:372
table::Key< geom::Angle > longitude
Definition: VisitInfo.cc:166
lsst::afw::coord::IcrsCoord IcrsCoord
Definition: misc.h:35
Point< double, 2 > Point2D
Definition: Point.h:300
virtual std::string toString() const
Get string representation.
Definition: Coord.cc:745
lsst::afw::geom::Point3D getVector() const
Return our contents in a position vector.
Definition: Coord.cc:355
double sec
Definition: Coord.cc:161
table::Key< int > b
T make_pair(T... args)
lsst::afw::geom::Angle angularSeparation(Coord const &c) const
compute the angular separation between two Coords
Definition: Coord.cc:506
virtual Fk5Coord toFk5() const
Convert outself from Topocentric to Fk5 (use current epoch)
Definition: Coord.cc:807
virtual Fk5Coord toFk5() const
Fk5 converter for IcrsCoord.
Definition: Coord.cc:715
T cos(T... args)
double x
constexpr double asAngularUnits(AngleUnit const &units) const noexcept
Return an Angle&#39;s value in the specified units.
Definition: Angle.h:138
T fabs(T... args)
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
virtual Fk5Coord toFk5() const
Convert ourself from Ecliptic to Fk5 (use current epoch)
Definition: Coord.cc:772
T asin(T... args)
A class to handle Fk5 coordinates (inherits from Coord)
Definition: Coord.h:348
std::shared_ptr< Coord > convert(CoordSystem system, double epoch=2000) const
Convert to a specified Coord type at a specified epoch.
Definition: Coord.cc:471
T find(T... args)
T size(T... args)
Extent< double, 3 > Extent3D
Definition: Extent.h:384
#define LSST_EXCEPT(type,...)
A class to handle Ecliptic coordinates (inherits from Coord)
Definition: Coord.h:490
virtual std::string toString() const
Get string representation.
Definition: Coord.cc:827
virtual void reset(lsst::afw::geom::Angle const longitude, lsst::afw::geom::Angle const latitude)
Definition: Coord.h:115
virtual std::string toString() const
Get string representation.
Definition: Coord.cc:967
AngleUnit constexpr arcseconds
constant with units of arcseconds
Definition: Angle.h:91
double getEpoch() const
Definition: Coord.h:131
virtual Fk5Coord toFk5() const
Convert ourself to Fk5: RA, Dec (use current epoch)
Definition: Coord.cc:570
Coord()
Default constructor for the Coord base class.
Definition: Coord.cc:324
lsst::afw::geom::Angle hmsStringToAngle(std::string const hms)
Convert a hh:mm:ss string to Angle.
Definition: Coord.cc:282
lsst::afw::geom::Angle getLongitude() const
get telescope longitude (positive values are E of Greenwich)
Definition: Observatory.cc:54
constexpr double asRadians() const noexcept
Return an Angle&#39;s value in radians.
Definition: Angle.h:141
virtual EclipticCoord toEcliptic() const
Convert ourself from Ecliptic to Ecliptic ...
Definition: Coord.cc:760
T tan(T... args)
virtual EclipticCoord toEcliptic(double const epoch) const
Convert ourself to Ecliptic: lambda, beta (precess to new epoch)
Definition: Coord.cc:618
std::pair< lsst::afw::geom::Angle, lsst::afw::geom::Angle > getOffsetFrom(Coord const &c) const
Compute the offset from a coordinate.
Definition: Coord.cc:518
int deg
Definition: Coord.cc:159
CoordSystem makeCoordEnum(std::string const system)
A utility function to get the enum value of a coordinate system from a string name.
Definition: Coord.cc:112
table::Key< int > a
Fk5Coord precess(double const epochTo) const
Precess ourselves from whence we are to a new epoch.
Definition: Coord.cc:660
T quiet_NaN(T... args)
T sqrt(T... args)
m
int sign
Definition: Coord.cc:162
virtual EclipticCoord toEcliptic() const
Convert ourself to Ecliptic: lambda, beta (use existing epoch)
Definition: Coord.cc:577
virtual GalacticCoord toGalactic() const
Convert ourself from Galactic to Galactic ...
Definition: Coord.cc:743
This is the base class for spherical coordinates.
Definition: Coord.h:63
Point< double, 3 > Point3D
Definition: Point.h:301
STL class.
virtual TopocentricCoord toTopocentric(Observatory const &obs, lsst::daf::base::DateTime const &obsDate) const
Convert ourself to Altitude/Azimuth: alt, az.
Definition: Coord.cc:579
A class to handle Icrs coordinates (inherits from Coord)
Definition: Coord.h:291
std::shared_ptr< Coord > averageCoord(std::vector< std::shared_ptr< Coord const >> const coords, CoordSystem system=UNKNOWN)
Return average of a list of coordinates.
Definition: Coord.cc:1001
virtual IcrsCoord toIcrs() const
Convert ourself to ICRS: RA, Dec (basically J2000)
Definition: Coord.cc:595
T reserve(T... args)
virtual std::string getClassName() const
Definition: Coord.h:147