/*
* 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;