BlinkenArea - GitList
Repositories
Blog
Wiki
libetherpix
Code
Commits
Branches
Tags
Search
Tree:
5bca604
Branches
Tags
master
libetherpix
simulator
bbox.cpp
implement drawing pixels
Stefan Schuermans
commited
5bca604
at 2017-06-10 23:09:20
bbox.cpp
Blame
History
Raw
/* * EtherPix simulator * * Copyright 2017 Stefan Schuermans <stefan schuermans info> * * 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, version 3 of the License. * * * 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 Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "bbox.h" /// constructor BBox::BBox(): m_init(false), m_x_min(0.0), m_x_max(0.0), m_y_min(0.0), m_y_max(0.0) { } /// reset bounding box (de-initialize) void BBox::reset() { m_init = false; m_x_min = 0.0; m_x_max = 0.0; m_y_min = 0.0; m_y_max = 0.0; } // add a point to the bounding box void BBox::add(double x, double y) { if (m_init) { if (x < m_x_min) m_x_min = x; if (x > m_x_max) m_x_max = x; if (y < m_y_min) m_y_min = y; if (y > m_y_max) m_y_max = y; } else { m_init = true; m_x_min = x; m_x_max = x; m_y_min = y; m_y_max = y; } } /** * @brief get coordinates * @return whether coordinates were there */ bool BBox::get(double &x_min, double &x_max, double &y_min, double &y_max) const { if (m_init) { x_min = m_x_min; x_max = m_x_max; y_min = m_y_min; y_max = m_y_max; return true; } else { return false; } }