Commit 13c8995b7caf899c9c52a35d8f3b6c55a1071ab7

Authored by Andreas Specovius
Committed by Jürgen Knödlseder
1 parent 579b0208

Fixed issue in computation of dx arising when the coordinates are of opposite sign.

Showing 1 changed file with 12 additions and 1 deletions
src/sky/GSkyRegionRect.cpp
... ... @@ -753,8 +753,19 @@ bool GSkyRegionRect::overlaps(const GSkyRegion& reg) const
753 753 ***************************************************************************/
754 754 GSkyDir GSkyRegionRect::transform_to_local(const GSkyDir& skydir) const
755 755 {
  756 + // Get rid of negative right ascension coordinates
  757 + // (Surely there is a more clever way to to this)
  758 + double skydir_ra = skydir.ra();
  759 + if (skydir_ra < 0) {
  760 + skydir_ra += gammalib::twopi;
  761 + }
  762 + double centre_ra = m_centre.ra();
  763 + if (centre_ra < 0) {
  764 + centre_ra += gammalib::twopi;
  765 + }
  766 +
756 767 // Compute separation (in radians)
757   - double dx = skydir.ra() - m_centre.ra();
  768 + double dx = skydir_ra - centre_ra;
758 769 double dy = skydir.dec() - m_centre.dec();
759 770  
760 771 // Correction for spherical coordinate system
... ...