9 #include "3esvector3.h" 56 inline Vector4(
const T &scalar) :
x(scalar), y(scalar), z(scalar), w(scalar) {}
68 inline Vector4(
const T &
x,
const T &y,
const T &z,
const T &w) : x(x), y(y), z(z), w(w) {}
72 inline Vector4(
const T *array4) :
x(array4[0]), y(array4[1]), z(array4[2]), w(array4[3]) {}
83 explicit inline Vector4(
const Vector3<Q> &other,
const T &w) :
x(other.
x), y(other.y), z(other.z), w(w) {}
90 inline const T &
operator[](
int index)
const {
return v[index]; }
100 template <
typename Q>
131 bool isZero(
const T &epsilon = Epsilon)
const;
302 template <
typename T>
305 return x == other.
x && y == other.y && z == other.z && w == other.w;
309 template <
typename T>
312 return x != other.
x || y != other.y || z != other.z || w != other.w;
316 template <
typename T>
320 return distanceSquared <= epsilon * epsilon;
324 template <
typename T>
331 template <
typename T>
343 template <
typename T>
357 template <
typename T>
368 template <
typename T>
379 template <
typename T>
390 template <
typename T>
401 template <
typename T>
412 template <
typename T>
415 const T div = T(1) / scalar;
424 template <
typename T>
427 return x * other.
x + y * other.y + z * other.z + w * other.w;
431 template <
typename T>
434 return x * other.
x + y * other.y + z * other.z + w * other.w;
438 template <
typename T>
442 v.
x = y * other.z - z * other.y;
443 v.y = z * other.
x -
x * other.z;
444 v.z =
x * other.y - y * other.
x;
450 template <
typename T>
454 mag = std::sqrt(mag);
459 template <
typename T>
475 #endif // _3ESVECTOR4_H_ T normalise(const T &epsilon=Epsilon)
Attempts to normalise this vector.
Definition: 3esvector4.h:332
static const Vector4< T > axisx
The vector (1, 0, 0, 0).
Definition: 3esvector4.h:44
static const Vector4< T > axisw
The vector (0, 0, 0, 1).
Definition: 3esvector4.h:50
Vector4< T > & multiply(const T &scalar)
Multiplies all components in this vector by scalar.
Definition: 3esvector4.h:402
bool operator!=(const Vector4< T > &other) const
Exact inequality operator.
Definition: 3esvector4.h:310
Vector4< T > & operator-=(const T &scalar)
Arithmetic operator.
Definition: 3esvector4.h:221
Vector4< T > & subtract(const Vector4< T > &other)
Subtracts other from this vector (this - other).
Definition: 3esvector4.h:380
Vector4< T > operator-() const
Unarary negation operator.
Definition: 3esvector4.h:114
Vector3< T > xyz() const
Downcast this vector to a Vector3.
Definition: 3esvector4.h:229
bool operator==(const Vector4< T > &other) const
Exact equality operator.
Definition: 3esvector4.h:303
T dot3(const Vector4< T > &other) const
Calculates the dot as if using vectors in R3.
Definition: 3esvector4.h:432
bool isZero(const T &epsilon=Epsilon) const
Zero test with error.
Definition: 3esvector4.h:325
Vector4(const T *array4)
Initialisation from a array of at least length 4.
Definition: 3esvector4.h:72
Vector4(const T &scalar)
Initialises all members to scalar.
Definition: 3esvector4.h:56
Vector4< T > & operator/=(const T &scalar)
Arithmetic operator.
Definition: 3esvector4.h:225
const T & operator[](int index) const
Definition: 3esvector4.h:90
Vector4< T > & scale(const T &scalar)
An alias for multiply(const T &).
Definition: 3esvector4.h:187
T dot(const Vector4< T > &other) const
Calculates the dot product of this.other.
Definition: 3esvector4.h:425
T magnitude() const
Calculates the magnitude of this vector.
Definition: 3esvector4.h:451
bool isEqual(const Vector4< T > &other, const T &epsilon=Epsilon) const
Equality test with error.
Definition: 3esvector4.h:317
Vector4< T > & operator+=(const T &scalar)
Arithmetic operator.
Definition: 3esvector4.h:217
Definition: 3esbounds.h:13
static const Vector4< T > zero
A vector with all zero values.
Definition: 3esvector4.h:40
Vector4(const Vector3< Q > &other, const T &w)
Copy constructor from a Vector3 of a different numeric type.
Definition: 3esvector4.h:83
Represents a vector in R4.
Definition: 3esvector4.h:13
T & operator[](int index)
Index operator.
Definition: 3esvector4.h:88
Matrix3< T > operator*(const Matrix3< T > &a, const Matrix3< T > &b)
Performs the matrix multiplication AB.
Vector4(const Vector3< T > &other, const T &w)
Copy constructor from a Vector3.
Definition: 3esvector4.h:63
Vector4< T > & divide(const T &scalar)
Divides all components in this vector by scalar.
Definition: 3esvector4.h:413
Vector4< T > & operator*=(const T &scalar)
Arithmetic operator.
Definition: 3esvector4.h:223
static const Vector4< T > axisz
The vector (0, 0, 1, 0).
Definition: 3esvector4.h:48
Represents a vector in R3.
Definition: 3esvector3.h:14
Vector4< T > cross3(const Vector4< T > &other) const
Calculates the dot product with other in R3.
Definition: 3esvector4.h:439
Vector4()
Default constructor: undefined initialisation behaviour.
Definition: 3esvector4.h:53
Vector3< T > operator/(const Vector3< T > &a, const T &b)
Divides a vector by a scalar.
Definition: 3esvector3.h:297
Vector4< T > & operator-=(const Vector4 &other)
Arithmetic operator.
Definition: 3esvector4.h:219
Vector4(const Vector4< T > &other)
Copy constructor.
Definition: 3esvector4.h:59
T x
Direct data member access.
Definition: 3esvector4.h:30
static const Vector4< T > one
The vector (1, 1, 1, 1).
Definition: 3esvector4.h:42
Vector3< T > operator+(const Vector3< T > &a, const Vector3< T > &b)
Adds two vectors.
Definition: 3esvector3.h:244
Vector4< float > Vector4f
Defines a single precision vector.
Definition: 3esvector4.h:13
Vector4< T > & negate()
Negates all components of this vector.
Definition: 3esvector4.h:135
Vector4< T > & operator+=(const Vector4 &other)
Arithmetic operator.
Definition: 3esvector4.h:215
Vector4< T > negated() const
Returns a negated copy of this vector.
Definition: 3esvector4.h:139
T magnitudeSquared() const
Calculates the magnitude squared of this vector.
Definition: 3esvector4.h:460
Vector4< T > normalised(const T &epsilon=Epsilon) const
Returns a normalised copy of this vector.
Definition: 3esvector4.h:344
static const T Epsilon
The default epsilon value used comparison operators.
Definition: 3esvector4.h:37
Vector4< T > & add(const Vector4< T > &other)
Adds other to this vector.
Definition: 3esvector4.h:358
Vector4< double > Vector4d
Defines a double precision vector.
Definition: 3esvector4.h:18
T v[4]
Array representation of the vector members.
Definition: 3esvector4.h:33
Vector4(const T &x, const T &y, const T &z, const T &w)
Per coordinate initialisation.
Definition: 3esvector4.h:68
static const Vector4< T > axisy
The vector (0, 1, 0, 0).
Definition: 3esvector4.h:46
Vector4< T > & operator=(const Vector4< Q > &other)
Simple assignment operator from a different numeric type.
Definition: 3esvector4.h:101
Vector4< T > & operator=(const Vector4< T > &other)
Simple assignment operator.
Definition: 3esvector4.h:95
Vector4(const Vector4< Q > &other)
Copy constructor from a different numeric type.
Definition: 3esvector4.h:77