// This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Copyright Liam Girdwood 2003 #include #include "grid.hh" namespace Vega { Grid::Grid() { } Grid::~Grid() { } /*! \fn void Grid::clip(double ra_min, double dec_min, double ra_max , double dec_max) * \param ra_min Minimum RA * \param dec_min Minimum DEC * \param ra_max Maximum RA * \param dec_max Maximum DEC * * Clip the grid within the provided boundaries */ void Grid::clip(double ra_min, double dec_min, double ra_max , double dec_max) { m_min_ra = ra_min; if (m_min_ra < 0) m_min_ra = 0; m_max_ra = ra_max; if (m_max_ra > 360) m_max_ra = 360; m_min_dec = dec_min; if (m_min_dec < -90) m_min_dec = -90; m_max_dec = dec_max; if (m_max_dec > 90) m_max_dec = 90; } /*! \fn double Grid::get_stepsize () * \param fov Virtula sky filed of view * \return grid setsize * * Calculate the step size of the grid. */ double Grid::get_stepsize () { if (m_ra_fov < 1) return 1.0 / 6.0; if (m_ra_fov < 2) return 0.25; if (m_ra_fov < 5) return 0.5; if (m_ra_fov < 10) return 1; if (m_ra_fov < 20) return 5; if (m_ra_fov < 45) return 10; return 30; } /*! \fn int Grid::get_ra_lines (std::vector& ra_lines) * \param ra_lines Clipped grid lines. * \return number of lines * * Get RA grid lines. */ int Grid::get_ra_lines (std::vector& ra_lines, bool overlap) { int count = 0; if (!overlap) m_ra_fov = m_max_ra - m_min_ra; double stepsize = get_stepsize(); double start = floor((m_min_ra / stepsize)) * stepsize; double end = floor((m_max_ra / stepsize) + 1) * stepsize; for (double i = start; i < end; i += stepsize) { GridLine line; line.x1 = line.x2 = i; line.y1 = m_min_dec; line.y2 = m_max_dec; ra_lines.push_back(line); count++; } return count; } /*! \fn int Grid::get_dec_lines (std::vector& dec_lines) * \param dec_lines Clipped grid lines. * \return number of lines * * Get DEC grid lines. */ int Grid::get_dec_lines (std::vector& dec_lines) { int count = 0; double dec_fov = m_max_dec - m_min_dec; double stepsize = get_stepsize(); double start = floor((m_min_dec / stepsize)) * stepsize; double end = floor((m_max_dec / stepsize) + 1) * stepsize; for (double i = start; i < end; i += stepsize) { GridLine line; line.x1 = m_min_ra; line.y1 = line.y2 = i; line.x2 = m_max_ra; dec_lines.push_back(line); count ++; } return count; } /*! \fn int Grid::get_labelling (std::vector& posn, std::vector& value) * \param posn Label position * \param value Label value * \return number of labels * * Get grid labels. */ int Grid::get_labelling (std::vector& posn, std::vector& value) { } };