Ocean
|
This class implements a vector with four elements. More...
Public Types | |
typedef T | Type |
Definition of the used data type. More... | |
Public Member Functions | |
VectorT4 ()=default | |
Creates a new 2D vector with zeros as default values. More... | |
VectorT4 (const T &x, const T &y, const T &z, const T &w) noexcept | |
Creates a new 4D vector with four given elements. More... | |
VectorT4 (const VectorT3< T > &vector) noexcept | |
Creates a new homogeneous 4D vector by a 3D vector. More... | |
VectorT4 (const VectorT3< T > &vector, const T &w) noexcept | |
Creates a new 4D vector by a 3D vector and a following scalar. More... | |
VectorT4 (const T *valueArray) noexcept | |
Creates a new 4D vector with a given array of elements. More... | |
VectorT4 (const VectorT4< T > &vector) noexcept | |
Copies a vector. More... | |
template<typename U > | |
VectorT4 (const VectorT4< U > &vector) noexcept | |
Copies a vector with different element data type than T. More... | |
VectorT4< T > | normalized () const |
Returns the normalized vector. More... | |
VectorT4< T > | normalizedOrZero () const |
Returns the normalized vector. More... | |
VectorT4< T > | normalizedOrValue (const VectorT4< T > &value) const |
Returns the normalized vector. More... | |
bool | normalize () |
Normalizes this vector. More... | |
T | length () const |
Returns the length of the vector. More... | |
T | sqr () const |
Returns the square of the vector length. More... | |
T | angle (const VectorT4< T > &right) const |
Returns the angle between this vector and a second vectors. More... | |
bool | isParallel (const VectorT4< T > &right) const |
Returns whether two vectors are parallel. More... | |
bool | isOrthogonal (const VectorT4< T > &right) const |
Returns whether two vectors are orthogonal. More... | |
const T & | x () const noexcept |
Returns the x value. More... | |
T & | x () noexcept |
Returns the x value. More... | |
const T & | y () const noexcept |
Returns the y value. More... | |
T & | y () noexcept |
Returns the y value. More... | |
const T & | z () const noexcept |
Returns the z value. More... | |
T & | z () noexcept |
Returns the z value. More... | |
const T & | w () const noexcept |
Returns the w value. More... | |
T & | w () noexcept |
Returns the w value. More... | |
VectorT2< T > | xy () const noexcept |
Returns the x and y component of the vector as new 2D vector. More... | |
VectorT3< T > | xyz () const noexcept |
Returns the x, y and z component of the vector as new 3D vector. More... | |
const T * | data () const noexcept |
Returns an pointer to the vector elements. More... | |
T * | data () noexcept |
Returns an pointer to the vector elements. More... | |
bool | isNull () const |
Returns whether this vector is a null vector up to a small epsilon. More... | |
bool | isUnit (const T eps=NumericT< T >::eps()) const |
Returns whether this vector is a unit vector (whether the vector has the length 1). More... | |
bool | isEqual (const VectorT4< T > &vector, const T eps) const |
Returns whether two vectors are equal up to a specified epsilon. More... | |
VectorT4< T > & | operator= (const VectorT4< T > &vector) |
Copy assigns a vector. More... | |
bool | operator== (const VectorT4< T > &vector) const |
Returns whether two vectors are identical up to a small epsilon. More... | |
bool | operator!= (const VectorT4< T > &vector) const |
Returns whether two vectors are not identical up to a small epsilon. More... | |
VectorT4< T > | operator+ (const VectorT4< T > &vector) const |
Adds two vectors. More... | |
VectorT4< T > & | operator+= (const VectorT4< T > &vector) |
Adds and assigns two vectors. More... | |
VectorT4< T > | operator- (const VectorT4< T > &vector) const |
Subtracts two vectors. More... | |
VectorT4< T > & | operator-= (const VectorT4< T > &vector) |
Subtracts and assigns two vectors. More... | |
VectorT4< T > | operator- () const |
Returns the negated vector. More... | |
T | operator* (const VectorT4< T > &vector) const |
Returns the dot product of two vectors. More... | |
VectorT4< T > | operator* (const T &value) const |
Multiplies this vector with a scalar. More... | |
VectorT4< T > & | operator*= (const T &value) |
Multiplies and assigns this vector with a scalar. More... | |
VectorT4< T > | operator/ (const T &value) const |
Divides this vector by a scalar. More... | |
VectorT4< T > & | operator/= (const T &value) |
Divides and assigns this vector by a scalar. More... | |
bool | operator< (const VectorT4< T > &vector) const |
Compares two vector objects and returns whether the left vector represents a smaller value than the right vector. More... | |
const T & | operator[] (const unsigned int index) const noexcept |
Element access operator. More... | |
T & | operator[] (const unsigned int index) noexcept |
Element access operator. More... | |
const T & | operator() (const unsigned int index) const noexcept |
Element access operator. More... | |
T & | operator() (const unsigned int index) noexcept |
Element access operator. More... | |
const T * | operator() () const noexcept |
Access operator. More... | |
T * | operator() () noexcept |
Access operator. More... | |
size_t | operator() (const VectorT4< T > &vector) const |
Hash function. More... | |
std::vector< VectorT4< float > > | vectors2vectors (std::vector< VectorT4< float >> &&vectors) |
std::vector< VectorT4< double > > | vectors2vectors (std::vector< VectorT4< double >> &&vectors) |
std::vector< VectorT4< float > > | vectors2vectors (const std::vector< VectorT4< float >> &vectors) |
std::vector< VectorT4< double > > | vectors2vectors (const std::vector< VectorT4< double >> &vectors) |
Static Public Member Functions | |
template<typename U > | |
static std::vector< VectorT4< T > > | vectors2vectors (std::vector< VectorT4< U >> &&vectors) |
Converts vectors with specific data type to vectors with different data type. More... | |
template<typename U > | |
static std::vector< VectorT4< T > > | vectors2vectors (const std::vector< VectorT4< U >> &vectors) |
Converts vectors with specific data type to vectors with different data type. More... | |
template<typename U > | |
static std::vector< VectorT4< T > > | vectors2vectors (const VectorT4< U > *vectors, const size_t size) |
Converts vectors with specific data type to vectors with different data type. More... | |
Protected Attributes | |
T | values_ [4] = {T(0), T(0), T(0), T(0)} |
The four values of the vector, with element order x, y, z, w. More... | |
This class implements a vector with four elements.
The element order is: (x, y, z, w).
T | Data type of the vector elements. |
typedef T Ocean::VectorT4< T >::Type |
Definition of the used data type.
|
default |
Creates a new 2D vector with zeros as default values.
|
inlinenoexcept |
Creates a new 4D vector with four given elements.
x | X value |
y | Y value |
z | Z value |
w | W value |
|
inlineexplicitnoexcept |
Creates a new homogeneous 4D vector by a 3D vector.
The fourth parameter will be 1.
vector | The vector for the first three elements |
|
inlinenoexcept |
Creates a new 4D vector by a 3D vector and a following scalar.
vector | The vector for the first three elements |
w | Scalar value for the last element |
|
inlineexplicitnoexcept |
Creates a new 4D vector with a given array of elements.
valueArray | Array with at least four elements |
|
inlinenoexcept |
Copies a vector.
vector | 4D vector that is copied |
|
inlineexplicitnoexcept |
Copies a vector with different element data type than T.
vector | The 4D vector to copy |
U | The element data type of the second vector |
T Ocean::VectorT4< T >::angle | ( | const VectorT4< T > & | right | ) | const |
Returns the angle between this vector and a second vectors.
Beware: This vector must not be zero.
Beware: This function does not throw an exception if one or both vectors are zero.
In case, the angle cannot be determined -1 will be returned.
right | Second vector, must not be zero |
|
inlinenoexcept |
Returns an pointer to the vector elements.
|
inlinenoexcept |
Returns an pointer to the vector elements.
|
inline |
Returns whether two vectors are equal up to a specified epsilon.
vector | Second vector |
eps | Epsilon to be used, with range [0, infinity) |
|
inline |
Returns whether this vector is a null vector up to a small epsilon.
bool Ocean::VectorT4< T >::isOrthogonal | ( | const VectorT4< T > & | right | ) | const |
Returns whether two vectors are orthogonal.
A zero vector will not be orthogonal.
right | The right vector |
bool Ocean::VectorT4< T >::isParallel | ( | const VectorT4< T > & | right | ) | const |
Returns whether two vectors are parallel.
A zero vector will not be parallel.
right | The right vector |
|
inline |
Returns whether this vector is a unit vector (whether the vector has the length 1).
eps | Epsilon to be used, with range [0, infinity) |
|
inline |
Returns the length of the vector.
|
inline |
Normalizes this vector.
|
inline |
Returns the normalized vector.
Beware: This function does not throw an exception if this vector cannot be normalized.
Thus, ensure that this vector is not zero before calling this function.
Or even better, use different normalization functions like: normalizedOrZero(), normalizedOrValue(), or normalize().
In case, the vector cannot be normalized, an uninitialized vector will be returned (due to performance reasons).
|
inline |
Returns the normalized vector.
If this vector cannot be normalized the given vector is returned.
value | Vector that will be returned if the vector cannot be normalized |
|
inline |
Returns the normalized vector.
If this vector cannot be normalized the zero vector is returned.
|
inline |
Returns whether two vectors are not identical up to a small epsilon.
vector | Right vector |
|
inlinenoexcept |
Access operator.
|
inlinenoexcept |
Access operator.
|
inlinenoexcept |
Element access operator.
index | The index of the element to access, with range [0, 3] |
|
inlinenoexcept |
Element access operator.
index | The index of the element to access, with range [0, 3] |
|
inline |
Hash function.
vector | The vector for which the hash value will be determined |
|
inline |
Multiplies this vector with a scalar.
value | Scalar value |
|
inline |
Returns the dot product of two vectors.
vector | Right vector |
|
inline |
Multiplies and assigns this vector with a scalar.
value | Scalar value |
|
inline |
Adds two vectors.
vector | Right vector |
|
inline |
Adds and assigns two vectors.
vector | Right vector |
|
inline |
Returns the negated vector.
|
inline |
Subtracts two vectors.
vector | Right vector |
|
inline |
Subtracts and assigns two vectors.
vector | Right vector |
|
inline |
Divides this vector by a scalar.
Beware: This function does not throw an exception if the given value is zero.
Thus, ensure that given value is not zero before calling this function.
In case, the given value is zero, the result is undefined.
value | Scalar value to be used as denominator, must not be zero |
|
inline |
Divides and assigns this vector by a scalar.
Beware: This function does not throw an exception if the given value is zero.
Thus, ensure that given value is not zero before calling this function.
In case, the given value is zero, the result is undefined.
value | Scalar value to be used as denominator, must not be zero |
|
inline |
Compares two vector objects and returns whether the left vector represents a smaller value than the right vector.
First the first component of both vectors are compared, if these values are equal then the next components are compares and so on.
vector | The second vector to compare |
|
inline |
Copy assigns a vector.
vector | 4D vector that is copied |
|
inline |
Returns whether two vectors are identical up to a small epsilon.
vector | Right vector |
|
inlinenoexcept |
Element access operator.
index | The index of the element to access, with range [0, 3] |
|
inlinenoexcept |
Element access operator.
index | The index of the element to access, with range [0, 3] |
|
inline |
Returns the square of the vector length.
|
inline |
|
inline |
|
inlinestatic |
Converts vectors with specific data type to vectors with different data type.
vectors | The vectors to convert |
U | The element data type of the vectors to convert |
|
inlinestatic |
Converts vectors with specific data type to vectors with different data type.
vectors | The vectors to convert |
size | The number of vector to convert |
U | The element data type of the vectors to convert |
|
inline |
|
inline |
|
inlinestatic |
Converts vectors with specific data type to vectors with different data type.
vectors | The vectors to convert |
U | The element data type of the vectors to convert |
|
inlinenoexcept |
Returns the w value.
|
inlinenoexcept |
Returns the w value.
|
inlinenoexcept |
Returns the x value.
|
inlinenoexcept |
Returns the x value.
|
inlinenoexcept |
Returns the x and y component of the vector as new 2D vector.
|
inlinenoexcept |
Returns the x, y and z component of the vector as new 3D vector.
|
inlinenoexcept |
Returns the y value.
|
inlinenoexcept |
Returns the y value.
|
inlinenoexcept |
Returns the z value.
|
inlinenoexcept |
Returns the z value.
|
protected |
The four values of the vector, with element order x, y, z, w.