//***************************************************************
// Copyright 2008 Centre For Advanced Spatial Analysis, UCL
//
// Author: Joel Dearden, University College London
//
// Contact: j.dearden@ucl.ac.uk
//
// Joel Dearden,
// Centre for Advanced Spatial Analysis,
// University College London,
// 1-19 Torrington Place,
// London,
// WC1E 7HB
//
//
// This file is part of PedTrace.
//
// PedTrace 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 3 of the License, or
// (at your option) any later version.
//
// PedTrace 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 PedTrace. If not, see .
//
//***************************************************************
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
///
/// Summary description for PT2DExtents
///
///
namespace pedTrace
{
public class PT2DExtents
{
private float fMinX;
private float fMaxX;
private float fMinY;
private float fMaxY;
private bool fFirstPoint;
public PT2DExtents()
{
fMinX = 0.0f;
fMaxX = 0.0f;
fMinY = 0.0f;
fMaxY = 0.0f;
fFirstPoint = true;
}
public void addPoint(PTPoint p)
{
if (fFirstPoint)
{
fMinX = p.fX;
fMaxX = p.fX;
fMinY = p.fY;
fMaxY = p.fY;
fFirstPoint = false;
}
else
{
if (p.fX > fMaxX)
{
fMaxX = p.fX;
}
if (p.fX < fMinX)
{
fMinX = p.fX;
}
if (p.fY > fMaxY)
{
fMaxY = p.fY;
}
if (p.fY < fMinY)
{
fMinY = p.fY;
}
}
}
public float getWidth()
{
return fMaxX - fMinX;
}
public float getHeight()
{
return fMaxY - fMinY;
}
public PTPoint getCentre()
{
return new PTPoint( (fMinX + fMaxX) / 2,
(fMinY + fMaxY) / 2,
0
);
}
}
}