54 inline Vector3(
const T &scalar) :
x(scalar), y(scalar), z(scalar) {}
62 inline Vector3(
const T &
x,
const T &y,
const T &z) : x(x), y(y), z(z) {}
66 inline Vector3(
const T *array3) :
x(array3[0]), y(array3[1]), z(array3[2]) {}
78 inline const T &
operator[](
int index)
const {
return v[index]; }
85 inline const T &
operator[](
unsigned index)
const {
return v[index]; }
126 bool isZero(
const T &epsilon = Epsilon)
const;
305 template <
typename T>
308 return x == other.
x && y == other.y && z == other.z;
312 template <
typename T>
315 return x != other.
x || y != other.y || z != other.z;
319 template <
typename T>
323 return distanceSquared <= epsilon * epsilon;
327 template <
typename T>
334 template <
typename T>
346 template <
typename T>
360 template <
typename T>
370 template <
typename T>
380 template <
typename T>
390 template <
typename T>
400 template <
typename T>
410 template <
typename T>
413 const T div = T(1) / scalar;
421 template <
typename T>
424 return x * other.
x + y * other.y + z * other.z;
428 template <
typename T>
432 v.
x = y * other.z - z * other.y;
433 v.y = z * other.
x -
x * other.z;
434 v.z =
x * other.y - y * other.
x;
439 template <
typename T>
443 mag = std::sqrt(mag);
448 template <
typename T>
463 #endif // _3ESVECTOR3_H_ Vector3< T > & operator-=(const Vector3 &other)
Arithmetic operator.
Definition: 3esvector3.h:210
static const Vector3< T > axisz
The vector (0, 0, 1).
Definition: 3esvector3.h:48
bool isZero(const T &epsilon=Epsilon) const
Zero test with error.
Definition: 3esvector3.h:328
bool isEqual(const Vector3< T > &other, const T &epsilon=Epsilon) const
Equality test with error.
Definition: 3esvector3.h:320
Vector3< T > & divide(const T &scalar)
Divides all components in this vector by scalar.
Definition: 3esvector3.h:411
static const Vector3< T > axisx
The vector (1, 0, 0).
Definition: 3esvector3.h:44
bool operator!=(const Vector3< T > &other) const
Exact inequality operator.
Definition: 3esvector3.h:313
Vector3< T > yxz() const
Swizzle operation.
Definition: 3esvector3.h:227
Vector3< T > zxy() const
Swizzle operation.
Definition: 3esvector3.h:229
Vector3< T > & multiply(const T &scalar)
Multiplies all components in this vector by scalar.
Definition: 3esvector3.h:401
bool operator==(const Vector3< T > &other) const
Exact equality operator.
Definition: 3esvector3.h:306
static const Vector3< T > zero
A vector with all zero values.
Definition: 3esvector3.h:40
Vector3< T > cross(const Vector3< T > &other) const
Calculates the cross product of this x other.
Definition: 3esvector3.h:429
T & operator[](unsigned index)
Index operator.
Definition: 3esvector3.h:83
Vector3< T > xzy() const
Return a copy of this vector. Provided for swizzle completeness.
Definition: 3esvector3.h:223
Definition: 3esbounds.h:13
Vector3< T > operator-() const
Unarary negation operator.
Definition: 3esvector3.h:109
Vector3< T > & operator+=(const T &scalar)
Arithmetic operator.
Definition: 3esvector3.h:208
Vector3< T > & operator-=(const T &scalar)
Arithmetic operator.
Definition: 3esvector3.h:212
Vector3< float > Vector3f
Defines a single precision vector.
Definition: 3esvector3.h:14
Vector3(const Vector3< Q > &other)
Copy constructor from a different numeric type.
Definition: 3esvector3.h:71
Vector3(const T *array3)
Initialisation from a array of at least length 3.
Definition: 3esvector3.h:66
static const Vector3< T > axisy
The vector (0, 1, 0).
Definition: 3esvector3.h:46
Vector3< T > zyx() const
Swizzle operation.
Definition: 3esvector3.h:231
Matrix3< T > operator*(const Matrix3< T > &a, const Matrix3< T > &b)
Performs the matrix multiplication AB.
T magnitude() const
Calculates the magnitude of this vector.
Definition: 3esvector3.h:440
Vector3< T > & operator=(const Vector3< T > &other)
Simple assignment operator.
Definition: 3esvector3.h:90
Vector3< T > & scale(const T &scalar)
An alias for multiply(const T &).
Definition: 3esvector3.h:182
Vector3< T > & operator+=(const Vector3 &other)
Arithmetic operator.
Definition: 3esvector3.h:206
static const Vector3< T > one
The vector (1, 1, 1).
Definition: 3esvector3.h:42
Vector3< T > & operator/=(const T &scalar)
Arithmetic operator.
Definition: 3esvector3.h:216
const T & operator[](int index) const
Definition: 3esvector3.h:78
Represents a vector in R3.
Definition: 3esvector3.h:14
Vector3< T > xyz() const
Return a copy of this vector. Provided for swizzle completeness.
Definition: 3esvector3.h:221
Vector3< T > & subtract(const Vector3< T > &other)
Subtracts other from this vector (this - other).
Definition: 3esvector3.h:381
Vector3< T > operator/(const Vector3< T > &a, const T &b)
Divides a vector by a scalar.
Definition: 3esvector3.h:297
Vector3< T > & operator*=(const T &scalar)
Arithmetic operator.
Definition: 3esvector3.h:214
T magnitudeSquared() const
Calculates the magnitude squared of this vector.
Definition: 3esvector3.h:449
Vector3< T > normalised(const T &epsilon=Epsilon) const
Returns a normalised copy of this vector.
Definition: 3esvector3.h:347
Vector3< T > & add(const Vector3< T > &other)
Adds other to this vector.
Definition: 3esvector3.h:361
Vector3(const Vector3< T > &other)
Copy constructor.
Definition: 3esvector3.h:57
Vector3< T > & operator=(const Vector3< Q > &other)
Simple assignment operator from a different numeric type.
Definition: 3esvector3.h:96
T normalise(const T &epsilon=Epsilon)
Attempts to normalise this vector.
Definition: 3esvector3.h:335
Vector3(const T &scalar)
Initialises all members to scalar.
Definition: 3esvector3.h:54
T & operator[](int index)
Index operator.
Definition: 3esvector3.h:76
T x
Direct data member access.
Definition: 3esvector3.h:30
T v[3]
Array representation of the vector members.
Definition: 3esvector3.h:33
Vector3< T > operator+(const Vector3< T > &a, const Vector3< T > &b)
Adds two vectors.
Definition: 3esvector3.h:244
Vector3()
Default constructor: undefined initialisation behaviour.
Definition: 3esvector3.h:51
static const T Epsilon
The default epsilon value used comparison operators.
Definition: 3esvector3.h:37
const T & operator[](unsigned index) const
Definition: 3esvector3.h:85
Vector3< T > negated() const
Returns a negated copy of this vector.
Definition: 3esvector3.h:134
Vector3(const T &x, const T &y, const T &z)
Per coordinate initialisation.
Definition: 3esvector3.h:62
Vector3< double > Vector3d
Defines a double precision vector.
Definition: 3esvector3.h:18
Vector3< T > yzx() const
Swizzle operation.
Definition: 3esvector3.h:225
T dot(const Vector3< T > &other) const
Calculates the dot product of this.other.
Definition: 3esvector3.h:422
Vector3< T > & negate()
Negates all components of this vector.
Definition: 3esvector3.h:130