[1030] | 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 |
|
---|
| 31 |
|
---|
| 32 | // Start of CEGUI namespace section
|
---|
| 33 | namespace CEGUI
|
---|
| 34 | {
|
---|
| 35 |
|
---|
| 36 | /*!
|
---|
| 37 | \brief
|
---|
| 38 | Class used as a two dimensional vector (aka a Point)
|
---|
| 39 | */
|
---|
| 40 | class CEGUIEXPORT Vector2
|
---|
| 41 | {
|
---|
| 42 | public:
|
---|
| 43 | Vector2(void) {}
|
---|
| 44 | Vector2(float x, float y) : d_x(x), d_y(y) {}
|
---|
| 45 |
|
---|
| 46 | Vector2& operator*=(const Vector2& vec)
|
---|
| 47 | {
|
---|
| 48 | d_x *= vec.d_x;
|
---|
| 49 | d_y *= vec.d_y;
|
---|
| 50 |
|
---|
| 51 | return *this;
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | Vector2& operator/=(const Vector2& vec)
|
---|
| 55 | {
|
---|
| 56 | d_x /= vec.d_x;
|
---|
| 57 | d_y /= vec.d_y;
|
---|
| 58 |
|
---|
| 59 | return *this;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | Vector2& operator+=(const Vector2& vec)
|
---|
| 63 | {
|
---|
| 64 | d_x += vec.d_x;
|
---|
| 65 | d_y += vec.d_y;
|
---|
| 66 |
|
---|
| 67 | return *this;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | Vector2& operator-=(const Vector2& vec)
|
---|
| 71 | {
|
---|
| 72 | d_x -= vec.d_x;
|
---|
| 73 | d_y -= vec.d_y;
|
---|
| 74 |
|
---|
| 75 | return *this;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | Vector2 operator+(const Vector2& vec) const
|
---|
| 79 | {
|
---|
| 80 | return Vector2(d_x + vec.d_x, d_y + vec.d_y);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | Vector2 operator-(const Vector2& vec) const
|
---|
| 84 | {
|
---|
| 85 | return Vector2(d_x - vec.d_x, d_y - vec.d_y);
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | Vector2 operator*(const Vector2& vec) const
|
---|
| 89 | {
|
---|
| 90 | return Vector2(d_x * vec.d_x, d_y * vec.d_y);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | bool operator==(const Vector2& vec) const
|
---|
| 94 | {
|
---|
| 95 | return ((d_x == vec.d_x) && (d_y == vec.d_y));
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | bool operator!=(const Vector2& vec) const
|
---|
| 99 | {
|
---|
| 100 | return !(operator==(vec));
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | float d_x, d_y;
|
---|
| 104 | };
|
---|
| 105 |
|
---|
| 106 | /*!
|
---|
| 107 | \brief
|
---|
| 108 | Point class
|
---|
| 109 | */
|
---|
| 110 | typedef Vector2 Point;
|
---|
| 111 |
|
---|
| 112 |
|
---|
| 113 | /*!
|
---|
| 114 | \brief
|
---|
| 115 | Class used as a three dimensional vector
|
---|
| 116 | */
|
---|
| 117 | class CEGUIEXPORT Vector3
|
---|
| 118 | {
|
---|
| 119 | public:
|
---|
| 120 | Vector3(void) {}
|
---|
| 121 | Vector3(float x, float y, float z) : d_x(x), d_y(y), d_z(z) {}
|
---|
| 122 |
|
---|
| 123 | float d_x, d_y, d_z;
|
---|
| 124 | };
|
---|
| 125 |
|
---|
| 126 | } // End of CEGUI namespace section
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | #endif // end of guard _CEGUIVector_h_
|
---|