/usr/include/cegui-0.8.4/CEGUI/Vector.h is in libcegui-mk2-dev 0.8.4+dfsg-4ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | /***********************************************************************
created: 13/2/2011
author: Martin Preisler (reworked from code by Paul D Turner)
purpose: Defines interfaces for Vector classes
*************************************************************************/
/***************************************************************************
* Copyright (C) 2004 - 2011 Paul D Turner & The CEGUI Development Team
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************/
#ifndef _CEGUIVector_h_
#define _CEGUIVector_h_
#include "CEGUI/UDim.h"
#include <typeinfo>
#include <ostream>
// Start of CEGUI namespace section
namespace CEGUI
{
/*!
\brief
Class used as a two dimensional vector (aka a Point)
\par
This class is templated now, this allows us to use it as a Vector2 of floats,
ints or even UDims without replicating the code all over the place.
\par
For a simple Vector2 of floats (what was called Vector2 before), use Vector2f
as the T template parameter defaults to float to save fingertips.
*/
template<typename T>
class Vector2:
public AllocatedObject<Vector2<T> >
{
public:
typedef T value_type;
inline Vector2()
{}
inline Vector2(const T x, const T y):
d_x(x),
d_y(y)
{}
inline Vector2(const Vector2& v):
d_x(v.d_x),
d_y(v.d_y)
{}
inline Vector2& operator*=(const Vector2& vec)
{
d_x *= vec.d_x;
d_y *= vec.d_y;
return *this;
}
inline Vector2& operator/=(const Vector2& vec)
{
d_x /= vec.d_x;
d_y /= vec.d_y;
return *this;
}
inline Vector2& operator+=(const Vector2& vec)
{
d_x += vec.d_x;
d_y += vec.d_y;
return *this;
}
inline Vector2& operator-=(const Vector2& vec)
{
d_x -= vec.d_x;
d_y -= vec.d_y;
return *this;
}
inline Vector2 operator+(const Vector2& vec) const
{
return Vector2(d_x + vec.d_x, d_y + vec.d_y);
}
inline Vector2 operator-(const Vector2& vec) const
{
return Vector2(d_x - vec.d_x, d_y - vec.d_y);
}
inline Vector2 operator*(const Vector2& vec) const
{
return Vector2(d_x * vec.d_x, d_y * vec.d_y);
}
inline Vector2 operator/(const Vector2& vec) const
{
return Vector2(d_x / vec.d_x, d_y / vec.d_y);
}
inline Vector2 operator*(const T c) const
{
return Vector2(d_x * c, d_y * c);
}
inline Vector2& operator*=(const T c)
{
d_x *= c;
d_y *= c;
return *this;
}
inline Vector2 operator/(const T c) const
{
return Vector2(d_x / c, d_y / c);
}
inline bool operator==(const Vector2& vec) const
{
return ((d_x == vec.d_x) && (d_y == vec.d_y));
}
inline bool operator!=(const Vector2& vec) const
{
return !(operator==(vec));
}
/*!
\brief allows writing the vector2 to std ostream
*/
inline friend std::ostream& operator << (std::ostream& s, const Vector2& v)
{
s << "CEGUI::Vector2<" << typeid(T).name() << ">(" << v.d_x << ", " << v.d_y << ")";
return s;
}
//! \brief finger saving alias for Vector2(0, 0)
inline static Vector2 zero()
{
return Vector2(TypeSensitiveZero<T>(), TypeSensitiveZero<T>());
}
//! \brief finger saving alias for Vector2(1, 1)
inline static Vector2 one()
{
return Vector2(TypeSensitiveOne<T>(), TypeSensitiveOne<T>());
}
//! \brief finger saving alias for Vector2(1, 0)
inline static Vector2 one_x()
{
return Vector2(TypeSensitiveOne<T>(), TypeSensitiveZero<T>());
}
//! \brief finger saving alias for Vector2(0, 1)
inline static Vector2 one_y()
{
return Vector2(TypeSensitiveZero<T>(), TypeSensitiveOne<T>());
}
T d_x;
T d_y;
};
// the main reason for this is to keep C++ API in sync with other languages
typedef Vector2<float> Vector2f;
// we need to allow UVector2 to be multiplied by floats, this is the most elegant way to do that
inline Vector2<UDim> operator * (const Vector2<UDim>& v, const float c)
{
return Vector2<UDim>(v.d_x * c, v.d_y * c);
}
typedef Vector2<UDim> UVector2;
/*!
\brief
Class used as a three dimensional vector
\par
This class is templated now, this allows us to use it as a Vector3 of floats,
ints or even UDims without replicating the code all over the place.
\par
For a simple Vector3 of floats (what was called Vector3 before), use Vector3f
as the T template parameter defaults to float to save fingertips.
*/
template<typename T>
class Vector3:
public AllocatedObject<Vector3<T> >
{
public:
typedef T value_type;
inline Vector3()
{}
inline Vector3(const T x, const T y, const T z):
d_x(x),
d_y(y),
d_z(z)
{}
inline explicit Vector3(const Vector2<T>& v, const T z):
d_x(v.d_x),
d_y(v.d_y),
d_z(z)
{}
inline Vector3(const Vector3& v):
d_x(v.d_x),
d_y(v.d_y),
d_z(v.d_z)
{}
inline bool operator==(const Vector3& vec) const
{
return ((d_x == vec.d_x) && (d_y == vec.d_y) && (d_z == vec.d_z));
}
inline bool operator!=(const Vector3& vec) const
{
return !(operator==(vec));
}
inline Vector3 operator*(const T c) const
{
return Vector3(d_x * c, d_y * c, d_z * c);
}
inline Vector3 operator+(const Vector3& v) const
{
return Vector3(d_x + v.d_x, d_y + v.d_y, d_z + v.d_z);
}
inline Vector3 operator-(const Vector3& v) const
{
return Vector3(d_x - v.d_x, d_y - v.d_y, d_z - v.d_z);
}
/*!
\brief allows writing the vector3 to std ostream
*/
inline friend std::ostream& operator << (std::ostream& s, const Vector3& v)
{
s << "CEGUI::Vector3<" << typeid(T).name() << ">(" << v.d_x << ", " << v.d_y << ", " << v.d_z << ")";
return s;
}
//! \brief finger saving alias for Vector3(0, 0, 0)
inline static Vector3 zero()
{
return Vector3(TypeSensitiveZero<T>(), TypeSensitiveZero<T>(), TypeSensitiveZero<T>());
}
//! \brief finger saving alias for Vector3(1, 1, 1)
inline static Vector3 one()
{
return Vector3(TypeSensitiveOne<T>(), TypeSensitiveOne<T>(), TypeSensitiveOne<T>());
}
//! \brief finger saving alias for Vector3(1, 0, 0)
inline static Vector3 one_x()
{
return Vector3(TypeSensitiveOne<T>(), TypeSensitiveZero<T>(), TypeSensitiveZero<T>());
}
//! \brief finger saving alias for Vector3(0, 1, 0)
inline static Vector3 one_y()
{
return Vector3(TypeSensitiveZero<T>(), TypeSensitiveOne<T>(), TypeSensitiveZero<T>());
}
//! \brief finger saving alias for Vector3(0, 0, 1)
inline static Vector3 one_z()
{
return Vector3(TypeSensitiveZero<T>(), TypeSensitiveZero<T>(), TypeSensitiveOne<T>());
}
T d_x;
T d_y;
T d_z;
};
// the main reason for this is to keep C++ API in sync with other languages
typedef Vector3<float> Vector3f;
} // End of CEGUI namespace section
#endif // end of guard _CEGUIVector_h_
|