GammaLib
2.1.0.dev
|
Interface for the rectangular sky region class. More...
#include <GSkyRegionRectangle.hpp>
Public Member Functions | |
GSkyRegionRectangle (void) | |
Void constructor. More... | |
GSkyRegionRectangle (const GSkyDir ¢re, const double &width, const double &height, const double &posang) | |
Sky direction constructor. More... | |
GSkyRegionRectangle (const double &ra, const double &dec, const double &width, const double &height, const double &posang) | |
Right Ascension and Declination constructor. More... | |
GSkyRegionRectangle (const std::string &line) | |
String constructor. More... | |
GSkyRegionRectangle (const GSkyRegionRectangle ®ion) | |
Copy constructor. More... | |
virtual | ~GSkyRegionRectangle (void) |
Destructor. More... | |
GSkyRegionRectangle & | operator= (const GSkyRegionRectangle ®ion) |
Assignment operator. More... | |
void | clear (void) |
Clear instance. More... | |
GSkyRegionRectangle * | clone (void) const |
Clone rectangular sky region. More... | |
std::string | classname (void) const |
Return class name. More... | |
const GSkyDir & | centre (void) const |
Return rectangular region centre. More... | |
void | centre (const GSkyDir ¢re) |
Set rectangular region centre. More... | |
void | centre (const double &ra, const double &dec) |
Set rectangular region centre Right Ascension and Declincation. More... | |
double | ra (void) const |
Return rectangular region centre Right Ascension. More... | |
double | dec (void) const |
Return rectangular region centre Declination. More... | |
const double & | width (void) const |
Return region width extension (in degrees) More... | |
void | width (const double &width) |
Set width of rectangular region. More... | |
const double & | height (void) const |
Return region height extension (in degrees) More... | |
void | height (const double &height) |
Set height of rectangular region. More... | |
const double & | posang (void) const |
Return region position angle (in degrees) More... | |
void | posang (const double &posang) |
Set position angle of rectangular region. More... | |
GSkyDir | corner (const int &index) const |
Return sky direction of one corner of the rectangle. More... | |
void | read (const std::string &line) |
Read region from DS9 string. More... | |
std::string | write (void) const |
Write region into a string. More... | |
bool | contains (const GSkyDir &dir) const |
Checks if sky direction lies within region. More... | |
bool | contains (const GSkyRegion ®) const |
Checks if region is fully contained within this region. More... | |
bool | overlaps (const GSkyRegion ®) const |
Checks if region is overlapping with this region. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print rectangular region. More... | |
Public Member Functions inherited from GSkyRegion | |
GSkyRegion (void) | |
Void constructor. More... | |
GSkyRegion (const GSkyRegion ®ion) | |
Copy constructor. More... | |
virtual | ~GSkyRegion (void) |
Destructor. More... | |
virtual GSkyRegion & | operator= (const GSkyRegion ®ion) |
Assignment operator. More... | |
const std::string & | type (void) const |
Return region type. More... | |
const std::string & | name (void) const |
Return region name. More... | |
const double & | solidangle (void) const |
Return solid angle of region. More... | |
void | type (const std::string &type) |
Set region type. More... | |
void | name (const std::string &name) |
Set region name. More... | |
void | solidangle (const double &solidangle) |
Set solid angle of region. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GSkyRegionRectangle ®ion) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | compute_solid_angle (void) |
Compute solid angle of rectangle. More... | |
bool | contains (const GSkyPixel &local) const |
Checks if local direction lies within region. More... | |
GSkyPixel | dir_to_local (const GSkyDir &dir) const |
Transform sky direction to local rectangle coordinates. More... | |
GSkyDir | local_to_dir (const GSkyPixel &local) const |
Transform local rectangle coordinates to sky direction. More... | |
Protected Member Functions inherited from GSkyRegion | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GSkyRegion ®ion) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GSkyDir | m_centre |
Centre or reference point of the region. More... | |
double | m_width |
Width of the region (degrees) More... | |
double | m_height |
Height of the region (degrees) More... | |
double | m_posang |
Position angle, counterclockwise from North (degrees) More... | |
Protected Attributes inherited from GSkyRegion | |
std::string | m_type |
Type of the region (circle, rectangle,...) More... | |
std::string | m_name |
Name of the region. More... | |
double | m_solid |
Solid angle subtended by the region (sr) More... | |
Interface for the rectangular sky region class.
This class provides an implementation for a rectangular sky region. The sky region is defined by an array of parameters, the meaning of which is specific to the derived class where the region type or shape is defined.
The class holds several properties such as solid angle subtended by the region and computed through internal method compute_solid().
The position angle counts counter-clockwise from celestial North and is aligned with the height axis of the rectangle. Note, that height and width describe the diameter of the region.
Sky directions can be transformed to the local/global coordinate system via the methods transform_to_local() / transform_to_global(). The position (in global coordinates) of the 4 corners of the rectangle can be received via the method get_corner(index).
Definition at line 62 of file GSkyRegionRectangle.hpp.
GSkyRegionRectangle::GSkyRegionRectangle | ( | void | ) |
Void constructor.
Definition at line 62 of file GSkyRegionRectangle.cpp.
References init_members().
Referenced by clone().
GSkyRegionRectangle::GSkyRegionRectangle | ( | const GSkyDir & | centre, |
const double & | width, | ||
const double & | height, | ||
const double & | posang | ||
) |
Sky direction constructor.
[in] | centre | Centre of rectangle. |
[in] | width | Region width (degrees). |
[in] | height | Region height (degrees). |
[in] | posang | Position angle (degrees). |
Definition at line 80 of file GSkyRegionRectangle.cpp.
References centre(), compute_solid_angle(), height(), init_members(), posang(), and width().
GSkyRegionRectangle::GSkyRegionRectangle | ( | const double & | ra, |
const double & | dec, | ||
const double & | width, | ||
const double & | height, | ||
const double & | posang | ||
) |
Right Ascension and Declination constructor.
[in] | ra | Right Ascension of region centre (degrees). |
[in] | dec | Declination of region centre (degrees). |
[in] | width | Region width (degrees). |
[in] | height | Region height (degrees). |
[in] | posang | Position angle (degrees). |
Definition at line 111 of file GSkyRegionRectangle.cpp.
References centre(), compute_solid_angle(), height(), init_members(), posang(), and width().
|
explicit |
String constructor.
[in] | line | DS9 region file line. |
Constructs region from a DS9 region file line.
Definition at line 141 of file GSkyRegionRectangle.cpp.
References init_members(), and read().
GSkyRegionRectangle::GSkyRegionRectangle | ( | const GSkyRegionRectangle & | region | ) |
Copy constructor.
[in] | region | Rectangular sky region. |
Definition at line 160 of file GSkyRegionRectangle.cpp.
References copy_members(), and init_members().
|
virtual |
|
inline |
Return rectangular region centre.
Returns the region centre.
Definition at line 144 of file GSkyRegionRectangle.hpp.
References m_centre.
Referenced by GSkyRegionRectangle(), read(), and GSkyRegionMap::set_region_rectangle().
|
inline |
Set rectangular region centre.
[in] | dir | Region centre. |
Sets the centre of the rectangular region to the specified sky direction.
Definition at line 158 of file GSkyRegionRectangle.hpp.
References m_centre.
|
inline |
Set rectangular region centre Right Ascension and Declincation.
[in] | ra | Right Ascension (degrees). |
[in] | dec | Declination (degrees). |
Sets the centre of the rectangular region to the specified Right Ascension and Declination.
Definition at line 175 of file GSkyRegionRectangle.hpp.
References m_centre, and GSkyDir::radec_deg().
|
inlinevirtual |
Return class name.
Implements GSkyRegion.
Definition at line 130 of file GSkyRegionRectangle.hpp.
|
virtual |
Clear instance.
Implements GSkyRegion.
Definition at line 232 of file GSkyRegionRectangle.cpp.
References GSkyRegion::free_members(), free_members(), GSkyRegion::init_members(), and init_members().
Referenced by read().
|
virtual |
Clone rectangular sky region.
Implements GSkyRegion.
Definition at line 252 of file GSkyRegionRectangle.cpp.
References GSkyRegionRectangle().
|
protected |
Compute solid angle of rectangle.
This method computes the solid angle of the rectangle in steradians and stores the result in the m_solid
member.
The solid angle is computed using
\[ \Omega = 2 {\rm width} \sin \left( \frac{\rm height}{2} \right) \]
where \({\rm width}\) and \({\rm height}\) are the width and the height of the rectangle expressed in radians.
Definition at line 861 of file GSkyRegionRectangle.cpp.
References gammalib::deg2rad, m_height, GSkyRegion::m_solid, m_width, and sin().
Referenced by GSkyRegionRectangle(), height(), read(), and width().
|
virtual |
Checks if sky direction lies within region.
[in] | dir | Sky direction. |
A sky direction lies within a region when its distance to the region centre is not larger than the region extension in both axes directions.
Implements GSkyRegion.
Definition at line 491 of file GSkyRegionRectangle.cpp.
References dir_to_local().
Referenced by contains(), and GSkyRegionMap::set_region_rectangle().
|
virtual |
Checks if region is fully contained within this region.
[in] | reg | Sky region. |
GException::feature_not_implemented | Not all region types supported currently. |
Implements GSkyRegion.
Definition at line 513 of file GSkyRegionRectangle.cpp.
References abs(), GSkyRegionCircle::centre(), contains(), corner(), dir_to_local(), G_CONTAINS, m_height, m_width, GSkyRegionMap::map(), GSkyRegionMap::nonzero_indices(), gammalib::rad2deg, GSkyRegionCircle::radius(), GSkyRegion::type(), GSkyPixel::x(), and GSkyPixel::y().
|
protected |
Checks if local direction lies within region.
[in] | local | Sky direction in local coordinate system. |
A local direction lies within a region when its distance to the region centre is not larger than the region extension in both axes directions.
Definition at line 879 of file GSkyRegionRectangle.cpp.
References abs(), contains(), m_height, m_width, gammalib::rad2deg, GSkyPixel::x(), and GSkyPixel::y().
|
protected |
Copy class members.
[in] | region | Rectangular sky region. |
Definition at line 823 of file GSkyRegionRectangle.cpp.
References m_centre, m_height, m_posang, and m_width.
Referenced by GSkyRegionRectangle(), and operator=().
GSkyDir GSkyRegionRectangle::corner | ( | const int & | index | ) | const |
Return sky direction of one corner of the rectangle.
[in] | index | Corner index [0,3] |
GException::out_of_range | Corner index is not in [0,3]. |
Returns the sky direction of one corner of the rectangle. The corner index
is counted counterclockwise from the positive Right Ascension and Declination directions:
index = 0
: \((\alpha + \frac{\rm width}{2}, \delta + \frac{\rm height}{2})\)index = 1
: \((\alpha + \frac{\rm width}{2}, \delta - \frac{\rm height}{2})\)index = 2
: \((\alpha - \frac{\rm width}{2}, \delta + \frac{\rm height}{2})\)index = 3
: \((\alpha - \frac{\rm width}{2}, \delta - \frac{\rm height}{2})\)where \(\alpha\) and \(\delta\) are the Right Ascension and Declination of the rectangle centre, and \({\rm width}\) and \({\rm height}\) are the width and height of the rectangle.
Definition at line 733 of file GSkyRegionRectangle.cpp.
References gammalib::deg2rad, G_CORNER, local_to_dir(), m_height, and m_width.
Referenced by GSkyRegionCircle::contains(), contains(), and GSkyRegionMap::set_region_rectangle().
|
inline |
Return rectangular region centre Declination.
Returns the region centre Declination in degrees.
Definition at line 204 of file GSkyRegionRectangle.hpp.
References GSkyDir::dec_deg(), and m_centre.
Referenced by print(), and GSkyRegionMap::set_region_rectangle().
Transform sky direction to local rectangle coordinates.
[in] | dir | Sky direction. |
Transform the sky direction dir
to the local cartesian coordinate system. The local coordinates \((x,y)\) are defined by
\[ x = d \sin(\phi) \]
and
\[ y = d \cos(\phi) \]
where \(d\) is the angular distance between the sky direction dir
and the centre of the rectangle in radians, and \(\phi\) is the position angle of the sky direction dir
with respect to the position angle of the rectangle, computed counter clockwise.
Definition at line 930 of file GSkyRegionRectangle.cpp.
References cos(), gammalib::deg2rad, GSkyDir::dist(), m_centre, m_posang, GSkyDir::posang(), and sin().
Referenced by contains(), and overlaps().
|
protected |
Delete class members.
Definition at line 839 of file GSkyRegionRectangle.cpp.
Referenced by clear(), operator=(), and ~GSkyRegionRectangle().
|
inline |
Return region height extension (in degrees)
Returns the region height extension in degrees.
Definition at line 232 of file GSkyRegionRectangle.hpp.
References m_height.
Referenced by GSkyRegionRectangle(), height(), overlaps(), print(), and read().
void GSkyRegionRectangle::height | ( | const double & | height | ) |
Set height of rectangular region.
[in] | height | Rectangle height (degrees). |
GException::invalid_argument | Height value is less than 0. |
Sets the height
of the rectangular sky region. Only non-negative heights are allowed.
Note that for a position angle of zero, the height axis is pointing to celestial north.
Definition at line 306 of file GSkyRegionRectangle.cpp.
References compute_solid_angle(), G_HEIGHT, height(), m_height, and gammalib::str().
|
protected |
Initialise class members.
Definition at line 804 of file GSkyRegionRectangle.cpp.
References GSkyDir::clear(), m_centre, m_height, m_posang, GSkyRegion::m_type, and m_width.
Referenced by clear(), GSkyRegionRectangle(), and operator=().
Transform local rectangle coordinates to sky direction.
[in] | local | Local rectangle coordinates. |
Transform the local coordinates local
to a sky direction. See GSkyRegionRectangle::dir_to_local for the relation between local rectangle coordinates and the sky direction.
Definition at line 958 of file GSkyRegionRectangle.cpp.
References gammalib::atan2(), gammalib::deg2rad, m_centre, m_posang, gammalib::pihalf, GSkyDir::rotate(), sqrt(), GSkyPixel::x(), and GSkyPixel::y().
Referenced by corner().
GSkyRegionRectangle & GSkyRegionRectangle::operator= | ( | const GSkyRegionRectangle & | region | ) |
Assignment operator.
[in] | region | Rectangular sky region. |
Definition at line 199 of file GSkyRegionRectangle.cpp.
References copy_members(), free_members(), init_members(), and GSkyRegion::operator=().
|
virtual |
Checks if region is overlapping with this region.
[in] | reg | Sky region. |
GException::feature_not_implemented | Regions differ in type. |
Checks whether a region overlaps with the rectangle.
Implements GSkyRegion.
Definition at line 625 of file GSkyRegionRectangle.cpp.
References abs(), GSkyRegionCircle::centre(), dir_to_local(), G_CONTAINS, height(), GSkyRegionMap::overlaps(), gammalib::rad2deg, GSkyRegionCircle::radius(), GSkyRegion::type(), width(), GSkyPixel::x(), and GSkyPixel::y().
Referenced by GSkyRegionCircle::overlaps().
|
inline |
Return region position angle (in degrees)
Returns the region position angle in degrees. The position angle is counted counterclockwise from North.
Definition at line 247 of file GSkyRegionRectangle.hpp.
References m_posang.
Referenced by GSkyRegionRectangle(), posang(), print(), and read().
|
inline |
Set position angle of rectangular region.
[in] | posang | Position angle (degrees). |
Sets the position angle of the rectangular sky region. The position angle is counted counterclockwise from celestial North and is aligned to the rectangle height.
Definition at line 263 of file GSkyRegionRectangle.hpp.
Print rectangular region.
[in] | chatter | Chattiness |
Implements GSkyRegion.
Definition at line 765 of file GSkyRegionRectangle.cpp.
References dec(), height(), gammalib::parformat(), posang(), ra(), SILENT, gammalib::str(), and width().
|
inline |
Return rectangular region centre Right Ascension.
Returns the region centre Right Ascension in degrees.
Definition at line 190 of file GSkyRegionRectangle.hpp.
References m_centre, and GSkyDir::ra_deg().
Referenced by print(), and GSkyRegionMap::set_region_rectangle().
|
virtual |
Read region from DS9 string.
[in] | line | String in DS9 format. |
GException::invalid_value | Invalid value found in DS9 format string. |
Implements GSkyRegion.
Definition at line 335 of file GSkyRegionRectangle.cpp.
References centre(), clear(), compute_solid_angle(), gammalib::contains(), G_READ, height(), GSkyDir::lb_deg(), GSkyRegion::m_name, posang(), GSkyDir::radec_deg(), gammalib::split(), gammalib::str(), gammalib::todouble(), and width().
Referenced by GSkyRegionRectangle(), and GSkyRegions::load().
|
inline |
Return region width extension (in degrees)
Returns the region width extension in degrees.
Definition at line 218 of file GSkyRegionRectangle.hpp.
References m_width.
Referenced by GSkyRegionRectangle(), overlaps(), print(), read(), and width().
void GSkyRegionRectangle::width | ( | const double & | width | ) |
Set width of rectangular region.
[in] | width | Rectangle width (degrees). |
GException::invalid_argument | Width value is less than 0. |
Sets the width
of the rectangular sky region. Only non-negative widths are allowed.
Definition at line 270 of file GSkyRegionRectangle.cpp.
References compute_solid_angle(), G_WIDTH, m_width, gammalib::str(), and width().
|
virtual |
Write region into a string.
Writes a DS9 region into a string. The region name is only written if it is defined.
Implements GSkyRegion.
Definition at line 453 of file GSkyRegionRectangle.cpp.
References GSkyDir::dec_deg(), m_centre, m_height, GSkyRegion::m_name, m_posang, m_width, GSkyDir::ra_deg(), and gammalib::str().
|
protected |
Centre or reference point of the region.
Definition at line 117 of file GSkyRegionRectangle.hpp.
Referenced by centre(), copy_members(), dec(), dir_to_local(), init_members(), local_to_dir(), ra(), and write().
|
protected |
Height of the region (degrees)
Definition at line 119 of file GSkyRegionRectangle.hpp.
Referenced by compute_solid_angle(), contains(), copy_members(), corner(), height(), init_members(), and write().
|
protected |
Position angle, counterclockwise from North (degrees)
Definition at line 120 of file GSkyRegionRectangle.hpp.
Referenced by copy_members(), dir_to_local(), init_members(), local_to_dir(), posang(), and write().
|
protected |
Width of the region (degrees)
Definition at line 118 of file GSkyRegionRectangle.hpp.
Referenced by compute_solid_angle(), contains(), copy_members(), corner(), init_members(), width(), and write().