/usr/include/OGRE/OgreVector4.h is in libogre-1.9-dev 1.9.0+dfsg1-1.
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 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
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 OR COPYRIGHT HOLDERS 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 __Vector4_H__
#define __Vector4_H__
#include "OgrePrerequisites.h"
#include "OgreVector3.h"
namespace Ogre
{
/** \addtogroup Core
* @{
*/
/** \addtogroup Math
* @{
*/
/** 4-dimensional homogeneous vector.
*/
class _OgreExport Vector4
{
public:
Real x, y, z, w;
public:
/** Default constructor.
@note
It does <b>NOT</b> initialize the vector for efficiency.
*/
inline Vector4()
{
}
inline Vector4( const Real fX, const Real fY, const Real fZ, const Real fW )
: x( fX ), y( fY ), z( fZ ), w( fW )
{
}
inline explicit Vector4( const Real afCoordinate[4] )
: x( afCoordinate[0] ),
y( afCoordinate[1] ),
z( afCoordinate[2] ),
w( afCoordinate[3] )
{
}
inline explicit Vector4( const int afCoordinate[4] )
{
x = (Real)afCoordinate[0];
y = (Real)afCoordinate[1];
z = (Real)afCoordinate[2];
w = (Real)afCoordinate[3];
}
inline explicit Vector4( Real* const r )
: x( r[0] ), y( r[1] ), z( r[2] ), w( r[3] )
{
}
inline explicit Vector4( const Real scaler )
: x( scaler )
, y( scaler )
, z( scaler )
, w( scaler )
{
}
inline explicit Vector4(const Vector3& rhs)
: x(rhs.x), y(rhs.y), z(rhs.z), w(1.0f)
{
}
/** Exchange the contents of this vector with another.
*/
inline void swap(Vector4& other)
{
std::swap(x, other.x);
std::swap(y, other.y);
std::swap(z, other.z);
std::swap(w, other.w);
}
inline Real operator [] ( const size_t i ) const
{
assert( i < 4 );
return *(&x+i);
}
inline Real& operator [] ( const size_t i )
{
assert( i < 4 );
return *(&x+i);
}
/// Pointer accessor for direct copying
inline Real* ptr()
{
return &x;
}
/// Pointer accessor for direct copying
inline const Real* ptr() const
{
return &x;
}
/** Assigns the value of the other vector.
@param
rkVector The other vector
*/
inline Vector4& operator = ( const Vector4& rkVector )
{
x = rkVector.x;
y = rkVector.y;
z = rkVector.z;
w = rkVector.w;
return *this;
}
inline Vector4& operator = ( const Real fScalar)
{
x = fScalar;
y = fScalar;
z = fScalar;
w = fScalar;
return *this;
}
inline bool operator == ( const Vector4& rkVector ) const
{
return ( x == rkVector.x &&
y == rkVector.y &&
z == rkVector.z &&
w == rkVector.w );
}
inline bool operator != ( const Vector4& rkVector ) const
{
return ( x != rkVector.x ||
y != rkVector.y ||
z != rkVector.z ||
w != rkVector.w );
}
inline Vector4& operator = (const Vector3& rhs)
{
x = rhs.x;
y = rhs.y;
z = rhs.z;
w = 1.0f;
return *this;
}
// arithmetic operations
inline Vector4 operator + ( const Vector4& rkVector ) const
{
return Vector4(
x + rkVector.x,
y + rkVector.y,
z + rkVector.z,
w + rkVector.w);
}
inline Vector4 operator - ( const Vector4& rkVector ) const
{
return Vector4(
x - rkVector.x,
y - rkVector.y,
z - rkVector.z,
w - rkVector.w);
}
inline Vector4 operator * ( const Real fScalar ) const
{
return Vector4(
x * fScalar,
y * fScalar,
z * fScalar,
w * fScalar);
}
inline Vector4 operator * ( const Vector4& rhs) const
{
return Vector4(
rhs.x * x,
rhs.y * y,
rhs.z * z,
rhs.w * w);
}
inline Vector4 operator / ( const Real fScalar ) const
{
assert( fScalar != 0.0 );
Real fInv = 1.0f / fScalar;
return Vector4(
x * fInv,
y * fInv,
z * fInv,
w * fInv);
}
inline Vector4 operator / ( const Vector4& rhs) const
{
return Vector4(
x / rhs.x,
y / rhs.y,
z / rhs.z,
w / rhs.w);
}
inline const Vector4& operator + () const
{
return *this;
}
inline Vector4 operator - () const
{
return Vector4(-x, -y, -z, -w);
}
inline friend Vector4 operator * ( const Real fScalar, const Vector4& rkVector )
{
return Vector4(
fScalar * rkVector.x,
fScalar * rkVector.y,
fScalar * rkVector.z,
fScalar * rkVector.w);
}
inline friend Vector4 operator / ( const Real fScalar, const Vector4& rkVector )
{
return Vector4(
fScalar / rkVector.x,
fScalar / rkVector.y,
fScalar / rkVector.z,
fScalar / rkVector.w);
}
inline friend Vector4 operator + (const Vector4& lhs, const Real rhs)
{
return Vector4(
lhs.x + rhs,
lhs.y + rhs,
lhs.z + rhs,
lhs.w + rhs);
}
inline friend Vector4 operator + (const Real lhs, const Vector4& rhs)
{
return Vector4(
lhs + rhs.x,
lhs + rhs.y,
lhs + rhs.z,
lhs + rhs.w);
}
inline friend Vector4 operator - (const Vector4& lhs, Real rhs)
{
return Vector4(
lhs.x - rhs,
lhs.y - rhs,
lhs.z - rhs,
lhs.w - rhs);
}
inline friend Vector4 operator - (const Real lhs, const Vector4& rhs)
{
return Vector4(
lhs - rhs.x,
lhs - rhs.y,
lhs - rhs.z,
lhs - rhs.w);
}
// arithmetic updates
inline Vector4& operator += ( const Vector4& rkVector )
{
x += rkVector.x;
y += rkVector.y;
z += rkVector.z;
w += rkVector.w;
return *this;
}
inline Vector4& operator -= ( const Vector4& rkVector )
{
x -= rkVector.x;
y -= rkVector.y;
z -= rkVector.z;
w -= rkVector.w;
return *this;
}
inline Vector4& operator *= ( const Real fScalar )
{
x *= fScalar;
y *= fScalar;
z *= fScalar;
w *= fScalar;
return *this;
}
inline Vector4& operator += ( const Real fScalar )
{
x += fScalar;
y += fScalar;
z += fScalar;
w += fScalar;
return *this;
}
inline Vector4& operator -= ( const Real fScalar )
{
x -= fScalar;
y -= fScalar;
z -= fScalar;
w -= fScalar;
return *this;
}
inline Vector4& operator *= ( const Vector4& rkVector )
{
x *= rkVector.x;
y *= rkVector.y;
z *= rkVector.z;
w *= rkVector.w;
return *this;
}
inline Vector4& operator /= ( const Real fScalar )
{
assert( fScalar != 0.0 );
Real fInv = 1.0f / fScalar;
x *= fInv;
y *= fInv;
z *= fInv;
w *= fInv;
return *this;
}
inline Vector4& operator /= ( const Vector4& rkVector )
{
x /= rkVector.x;
y /= rkVector.y;
z /= rkVector.z;
w /= rkVector.w;
return *this;
}
/** Calculates the dot (scalar) product of this vector with another.
@param
vec Vector with which to calculate the dot product (together
with this one).
@return
A float representing the dot product value.
*/
inline Real dotProduct(const Vector4& vec) const
{
return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
}
/// Check whether this vector contains valid values
inline bool isNaN() const
{
return Math::isNaN(x) || Math::isNaN(y) || Math::isNaN(z) || Math::isNaN(w);
}
/** Function for writing to a stream.
*/
inline _OgreExport friend std::ostream& operator <<
( std::ostream& o, const Vector4& v )
{
o << "Vector4(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")";
return o;
}
// special
static const Vector4 ZERO;
};
/** @} */
/** @} */
}
#endif
|