From 6aadb3f365990a5a8db8eb773c52bf7370f9e691 Mon Sep 17 00:00:00 2001 From: Andreas Specovius Date: Mon, 15 Jun 2020 15:47:12 +0200 Subject: [PATCH] Adapted contains() method to use local coordinate system. --- src/sky/GSkyRegionRect.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/sky/GSkyRegionRect.cpp b/src/sky/GSkyRegionRect.cpp index 7124799..549a192 100644 --- a/src/sky/GSkyRegionRect.cpp +++ b/src/sky/GSkyRegionRect.cpp @@ -555,30 +555,25 @@ std::string GSkyRegionRect::print(const GChatter& chatter) const * @param[in] dir Sky direction. * * A sky direction lies within a region when its distance to the region - * centre is not larger than the region radius. + * centre is not larger than the region extension in both axes directions. ***************************************************************************/ bool GSkyRegionRect::contains(const GSkyDir& dir) const { // Initialise return value bool dir_is_in = false; - // std::cout<<"GSkyRegionRect::contains: (1/2) dec: "<=(m_centre.dec_deg() - m_halfheight))) { + // Check containment: declination axis + if (std::abs(local_dir.dec_deg()) <= m_halfheight) { - // Compute width scaled for declination of queried skydir - double scale = std::cos(dir.dec()); - double half_width_scaled = m_halfwidth/scale; + // Check containment: right ascension axis + if (std::abs(local_dir.ra_deg()) <= m_halfwidth) { - // Check ra axis - if ((dir.ra_deg()<=(m_centre.ra_deg() + half_width_scaled)) && - (dir.ra_deg()>=(m_centre.ra_deg() - half_width_scaled))) { + // Sky direction is inside the rectangle dir_is_in = true; } - - // std::cout<<"GSkyRegionRect::contains: (2/2) ra: "<