Fixed autotools stuff
[construo.git] / rect.hxx
blob7e7c3d26f366b72716666b913392eddb8fa9dbd5
1 // $Id: rect.hxx,v 1.3 2003/01/04 20:12:38 grumbel Exp $
2 //
3 // Construo - A wire-frame construction gamee
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef HEADER_RECT_HXX
21 #define HEADER_RECT_HXX
23 #include "math.hxx"
24 #include "vector2d.hxx"
26 /** */
27 template<class T>
28 class Rect
30 private:
31 public:
32 T x1;
33 T y1;
34 T x2;
35 T y2;
37 Rect ()
41 Rect (const T& x1_,
42 const T& y1_,
43 const T& x2_,
44 const T& y2_)
45 : x1 (Math::min(x1_, x2_)),
46 y1 (Math::min(y1_, y2_)),
47 x2 (Math::max(x1_, x2_)),
48 y2 (Math::max(y1_, y2_))
51 T get_width ()
53 return x2 - x1;
56 T get_height ()
58 return x2 - x1;
61 Vector2d get_center () const
63 return Vector2d ((x1 + x2)/2.0f,
64 (y1 + y2)/2.0f);
68 #endif
70 /* EOF */