3es
0.7
|
Represents a vector in R3. More...
#include <3esvector3.h>
Public Member Functions | |
Vector3 () | |
Default constructor: undefined initialisation behaviour. | |
Vector3 (const T &scalar) | |
Initialises all members to scalar . More... | |
Vector3 (const Vector3< T > &other) | |
Copy constructor. More... | |
Vector3 (const T &x, const T &y, const T &z) | |
Per coordinate initialisation. More... | |
Vector3 (const T *array3) | |
Initialisation from a array of at least length 3. More... | |
template<typename Q > | |
Vector3 (const Vector3< Q > &other) | |
Copy constructor from a different numeric type. More... | |
T & | operator[] (int index) |
Index operator. More... | |
const T & | operator[] (int index) const |
T & | operator[] (unsigned index) |
Index operator. More... | |
const T & | operator[] (unsigned index) const |
Vector3< T > & | operator= (const Vector3< T > &other) |
Simple assignment operator. More... | |
template<typename Q > | |
Vector3< T > & | operator= (const Vector3< Q > &other) |
Simple assignment operator from a different numeric type. More... | |
bool | operator== (const Vector3< T > &other) const |
Exact equality operator. More... | |
bool | operator!= (const Vector3< T > &other) const |
Exact inequality operator. More... | |
Vector3< T > | operator- () const |
Unarary negation operator. More... | |
bool | isEqual (const Vector3< T > &other, const T &epsilon=Epsilon) const |
Equality test with error. More... | |
bool | isZero (const T &epsilon=Epsilon) const |
Zero test with error. More... | |
Vector3< T > & | negate () |
Negates all components of this vector. More... | |
Vector3< T > | negated () const |
Returns a negated copy of this vector. More... | |
T | normalise (const T &epsilon=Epsilon) |
Attempts to normalise this vector. More... | |
Vector3< T > | normalised (const T &epsilon=Epsilon) const |
Returns a normalised copy of this vector. More... | |
Vector3< T > & | add (const Vector3< T > &other) |
Adds other to this vector. More... | |
Vector3< T > & | add (const T &scalar) |
Adds scalar to all components in this vector. More... | |
Vector3< T > & | subtract (const Vector3< T > &other) |
Subtracts other from this vector (this - other). More... | |
Vector3< T > & | subtract (const T &scalar) |
Subtracts scalar from all components in this vector. More... | |
Vector3< T > & | multiply (const T &scalar) |
Multiplies all components in this vector by scalar . More... | |
Vector3< T > & | scale (const T &scalar) |
An alias for multiply(const T &) . More... | |
Vector3< T > & | divide (const T &scalar) |
Divides all components in this vector by scalar . More... | |
T | dot (const Vector3< T > &other) const |
Calculates the dot product of this.other. More... | |
Vector3< T > | cross (const Vector3< T > &other) const |
Calculates the cross product of this x other. More... | |
T | magnitude () const |
Calculates the magnitude of this vector. More... | |
T | magnitudeSquared () const |
Calculates the magnitude squared of this vector. More... | |
Vector3< T > & | operator+= (const Vector3 &other) |
Arithmetic operator. | |
Vector3< T > & | operator+= (const T &scalar) |
Arithmetic operator. | |
Vector3< T > & | operator-= (const Vector3 &other) |
Arithmetic operator. | |
Vector3< T > & | operator-= (const T &scalar) |
Arithmetic operator. | |
Vector3< T > & | operator*= (const T &scalar) |
Arithmetic operator. | |
Vector3< T > & | operator/= (const T &scalar) |
Arithmetic operator. | |
Vector3< T > | xyz () const |
Return a copy of this vector. Provided for swizzle completeness. | |
Vector3< T > | xzy () const |
Return a copy of this vector. Provided for swizzle completeness. | |
Vector3< T > | yzx () const |
Swizzle operation. | |
Vector3< T > | yxz () const |
Swizzle operation. | |
Vector3< T > | zxy () const |
Swizzle operation. | |
Vector3< T > | zyx () const |
Swizzle operation. | |
Public Attributes | |
union { | |
struct { | |
T x | |
Direct data member access. | |
T y | |
T z | |
} | |
T v [3] | |
Array representation of the vector members. | |
}; | |
Static Public Attributes | |
static const T | Epsilon = T(1e-6) |
The default epsilon value used comparison operators. | |
static const Vector3< T > | zero |
A vector with all zero values. | |
static const Vector3< T > | one |
The vector (1, 1, 1). | |
static const Vector3< T > | axisx |
The vector (1, 0, 0). | |
static const Vector3< T > | axisy |
The vector (0, 1, 0). | |
static const Vector3< T > | axisz |
The vector (0, 0, 1). | |
Represents a vector in R3.
|
inline |
Initialises all members to scalar
.
scalar | The value for all members. |
|
inline |
Copy constructor.
other | Vector to copy the value of. |
|
inline |
Per coordinate initialisation.
x | The x coordinate. |
y | The y coordinate. |
z | The z coordinate. |
|
inline |
Initialisation from a array of at least length 3.
No bounds checking is performed.
array3 | An array of at least length 3. Copies elements (0, 1, 2). |
|
inlineexplicit |
Copy constructor from a different numeric type.
other | Vector to copy the value of. |
|
inline |
Adds other
to this vector.
Component-wise addition.
other | The operand. |
Referenced by tes::Vector3< float >::negated(), tes::operator+(), and tes::Vector3< float >::operator+=().
|
inline |
Adds scalar
to all components in this vector.
scalar | The scalar value to add. |
|
inline |
Calculates the cross product of this x other.
Referenced by tes::Vector3< float >::scale().
|
inline |
Divides all components in this vector by scalar
.
scalar | The scalar value to divide by. Performs no operation if scalar is zero. |
Referenced by tes::Vector3< float >::normalise(), tes::Vector3< float >::normalised(), tes::operator/(), tes::Vector3< float >::operator/=(), and tes::Vector3< float >::scale().
|
inline |
Calculates the dot product of this.other.
Referenced by tes::planegeom::fromNormalAndPoint(), tes::Vector3< float >::magnitudeSquared(), tes::Vector3< float >::scale(), tes::Capsule::setAxis(), tes::Cylinder::setAxis(), tes::Cone::setDirection(), tes::Arrow::setDirection(), and tes::Text3D::Text3D().
|
inline |
Equality test with error.
Defaults to using Epsilon
.
The vectors are considered equal if the distance between the vectors is less than epsilon
.
other | The vector to compare to. |
epsilon | The error tolerance. |
other
are equal with epsilon
. Referenced by tes::Vector3< float >::isZero(), and tes::Vector3< float >::operator-().
|
inline |
Zero test with error.
Defaults to using Epsilon
.
The vector is considered zero if the distance to zero less than epsilon
.
epsilon | The error tolerance. |
epsilon
of zero. Referenced by tes::Vector3< float >::operator-().
|
inline |
Calculates the magnitude of this vector.
Referenced by tes::Vector3< float >::normalise(), tes::Vector3< float >::normalised(), and tes::Vector3< float >::scale().
|
inline |
Calculates the magnitude squared of this vector.
Referenced by tes::Vector3< float >::isEqual(), tes::Vector3< float >::magnitude(), and tes::Vector3< float >::scale().
|
inline |
Multiplies all components in this vector by scalar
.
scalar | The scalar value to multiply by. |
Referenced by tes::Vector3< float >::negated(), tes::operator*(), tes::Vector3< float >::operator*=(), and tes::Vector3< float >::scale().
|
inline |
Negates all components of this vector.
|
inline |
Returns a negated copy of this vector.
This vector is unchanged.
Referenced by tes::Vector3< float >::operator-().
|
inline |
Attempts to normalise this vector.
Normalisation fails if the length of this vector is less than or equal to epsilon
. In this case, the vector remains unchanged.
Referenced by tes::Vector3< float >::negated().
|
inline |
Returns a normalised copy of this vector.
Normalisation fails if the length of this vector is less than or equal to epsilon
.
Referenced by tes::Vector3< float >::negated().
|
inline |
Exact inequality operator.
Compares each component with the same operator.
other | The vector to compare to. |
other
. Referenced by tes::Vector3< float >::operator=().
|
inline |
|
inline |
Simple assignment operator.
other | Vector to copy the value of. |
|
inline |
Simple assignment operator from a different numeric type.
other | Vector to copy the value of. |
|
inline |
Exact equality operator.
Compares each component with the same operator.
other | The vector to compare to. |
other
. Referenced by tes::Vector3< float >::operator=().
|
inline |
Index operator.
Not bounds checked.
index | Access coordinates by index; 0 = x, 1 = y, 2 = z. |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Index operator.
Not bounds checked.
index | Access coordinates by index; 0 = x, 1 = y, 2 = z. |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
An alias for multiply(const T &)
.
scalar | The scalar value to multiply by. |
|
inline |
Subtracts other
from this vector (this - other).
Component-wise subtraction.
other | The operand. |
Referenced by tes::Vector3< float >::negated(), tes::operator-(), and tes::Vector3< float >::operator-=().
|
inline |
Subtracts scalar
from all components in this vector.
scalar | The scalar value to subtract. |