source: GTP/trunk/Lib/Geom/OgreStuff/include/CEGUI/CEGUIVector.h @ 1809

Revision 1809, 3.0 KB checked in by gumbau, 18 years ago (diff)
Line 
1/************************************************************************
2        filename:       CEGUIVector.h
3        created:        14/3/2004
4        author:         Paul D Turner
5       
6        purpose:        Defines interfaces for Vector classes
7*************************************************************************/
8/*************************************************************************
9    Crazy Eddie's GUI System (http://www.cegui.org.uk)
10    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
11
12    This library is free software; you can redistribute it and/or
13    modify it under the terms of the GNU Lesser General Public
14    License as published by the Free Software Foundation; either
15    version 2.1 of the License, or (at your option) any later version.
16
17    This library is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    Lesser General Public License for more details.
21
22    You should have received a copy of the GNU Lesser General Public
23    License along with this library; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25*************************************************************************/
26#ifndef _CEGUIVector_h_
27#define _CEGUIVector_h_
28
29#include "CEGUIBase.h"
30#include "CEGUISize.h"
31
32
33// Start of CEGUI namespace section
34namespace CEGUI
35{
36
37/*!
38\brief
39        Class used as a two dimensional vector (aka a Point)
40*/
41class CEGUIEXPORT Vector2
42{
43public:
44        Vector2(void) {}
45        Vector2(float x, float y) : d_x(x), d_y(y) {}
46
47        Vector2& operator*=(const Vector2& vec)
48        {
49                d_x *= vec.d_x;
50                d_y *= vec.d_y;
51
52                return *this;
53        }
54
55        Vector2& operator/=(const Vector2& vec)
56        {
57                d_x /= vec.d_x;
58                d_y /= vec.d_y;
59
60                return *this;
61        }
62
63        Vector2& operator+=(const Vector2& vec)
64        {
65                d_x += vec.d_x;
66                d_y += vec.d_y;
67
68                return *this;
69        }
70
71        Vector2& operator-=(const Vector2& vec)
72        {
73                d_x -= vec.d_x;
74                d_y -= vec.d_y;
75
76                return *this;
77        }
78
79        Vector2 operator+(const Vector2& vec) const
80        {
81                return Vector2(d_x + vec.d_x, d_y + vec.d_y);
82        }
83
84        Vector2 operator-(const Vector2& vec) const
85        {
86                return Vector2(d_x - vec.d_x, d_y - vec.d_y);
87        }
88
89        Vector2 operator*(const Vector2& vec) const
90        {
91                return Vector2(d_x * vec.d_x, d_y * vec.d_y);
92        }
93
94        bool    operator==(const Vector2& vec) const
95        {
96                return ((d_x == vec.d_x) && (d_y == vec.d_y));
97        }
98
99        bool    operator!=(const Vector2& vec) const
100        {
101                return !(operator==(vec));
102        }
103
104    Size asSize() const     { return Size(d_x, d_y); }
105
106        float d_x, d_y;
107};
108
109/*!
110\brief
111        Point class
112*/
113typedef Vector2         Point;
114
115
116/*!
117\brief
118        Class used as a three dimensional vector
119*/
120class CEGUIEXPORT Vector3
121{
122public:
123        Vector3(void) {}
124        Vector3(float x, float y, float z) : d_x(x), d_y(y), d_z(z) {}
125
126        float   d_x, d_y, d_z;
127};
128
129} // End of  CEGUI namespace section
130
131
132#endif  // end of guard _CEGUIVector_h_
Note: See TracBrowser for help on using the repository browser.