Vector representing a point in three-dimensional space. More...
#include <ptems/vector.hpp>
Public Types | |
using | ConjugateType = BasicVector< typename std::conditional_t< is_complex_v< T >, T, std::complex< T > >, 3 > |
The type of the conjugate of the vector. More... | |
Public Member Functions | |
constexpr | BasicVector () |
Construct a zero vector. More... | |
constexpr | BasicVector (T value) |
Construct a vector with all components equal to the specified value. More... | |
constexpr | BasicVector (T x, T y, T z) |
Construct a vector for the specified point. More... | |
template<typename U > | |
constexpr | BasicVector (const BasicVector< U, 3 > rhs) |
Construct a vector by copying the specified vector. More... | |
template<typename U > | |
constexpr BasicVector & | operator= (const BasicVector< U, 3 > rhs) |
Copy the specified vector to this. More... | |
constexpr BasicVector & | operator= (T rhs) |
Set all components tof vector equal to a constants. More... | |
BasicVector< T, 2 > | XY () const |
Swizzle function to get 2D vector containing x & y components. More... | |
BasicVector< T, 2 > | XZ () const |
Swizzle function to get 2D vector containing x & z components. More... | |
BasicVector< T, 2 > | YZ () const |
Swizzle function to get 2D vector containing y & z components. More... | |
template<typename U > | |
constexpr BasicVector & | operator+= (const BasicVector< U, 3 > &rhs) |
Adds another 3D vector to this vector. More... | |
constexpr BasicVector & | operator+= (T rhs) |
Adds a scalar to this vector. More... | |
template<typename U > | |
constexpr BasicVector & | operator-= (const BasicVector< U, 3 > &rhs) |
Subtracts another 3D vector to this vector. More... | |
constexpr BasicVector & | operator-= (T rhs) |
Subtracts a scalar from this vector. More... | |
template<typename U > | |
constexpr BasicVector & | operator/= (U rhs) |
Divides all components of this vector by a constant. More... | |
template<typename U > | |
constexpr BasicVector & | operator/= (const BasicVector< U, 3 > &rhs) |
Performs elementwise division of all components of this vector by the other vector. More... | |
template<typename U > | |
constexpr BasicVector & | operator*= (U rhs) |
Multiplies all components of this vector by a constant. More... | |
template<typename U > | |
constexpr BasicVector & | operator*= (const BasicVector< U, 3 > &rhs) |
Performs elementwise multiplication of all components of this vector by the other vector. More... | |
constexpr BasicVector | operator- () const |
Returns the negated vector. More... | |
template<typename U > | |
constexpr std::common_type_t< T, U > | Dot (const BasicVector< U, 3 > &rhs) const |
Computes the dot product of this vector with the specified vector. More... | |
template<typename U > | |
constexpr BasicVector< std::common_type_t< T, U >, 3 > | Cross (const BasicVector< U, 3 > &rhs) const |
Computes the cross product of this vector with the specified vector. More... | |
constexpr BasicVector & | Normalise () |
Normalises the current vector. More... | |
constexpr BasicVector | Normalised () const |
Gets a new vector which is the normalised version of this vector. More... | |
template<typename U , typename = std::enable_if_t<!is_complex_v<T> && !is_complex_v<U>>> | |
std::common_type_t< T, U > | Angle (const BasicVector< U, 3 > &rhs) const |
Computes the angle between the specified vector and the current vector. More... | |
constexpr T | operator[] (std::size_t i) const |
Gets a component of the vector by index. More... | |
constexpr T & | operator[] (std::size_t i) |
Gets a mutable reference to the component of the vector by index. More... | |
constexpr remove_complex_t< T > | Length () const |
Computes the length of the vector. More... | |
constexpr remove_complex_t< T > | LengthSquared () const |
Gets the square of the length of the vector. More... | |
ConjugateType | Conjugate () const |
Computes the complex conjugate of the vector. More... | |
BasicVector & | ConjugateOverwrite () const |
Overwrites the vector with its complex conjugate. More... | |
std::size_t | size () const |
Gets the number of elements in the vector. More... | |
Public Attributes | |
T | X |
The x-component of the vector. More... | |
T | Y |
The y-component of the vector. More... | |
T | Z |
The z-component of the vector. More... | |
Vector representing a point in three-dimensional space.
using ptems::BasicVector< T, 3 >::ConjugateType = BasicVector<typename std::conditional_t<is_complex_v<T>, T, std::complex<T> >,3> |
The type of the conjugate of the vector.
Will either be the same type if T is complex, otherwise a vector of std::complex<T>.
|
inlineconstexpr |
Construct a zero vector.
|
inlineexplicitconstexpr |
Construct a vector with all components equal to the specified value.
value | Value to fill in each component of the vector |
|
inlineconstexpr |
Construct a vector for the specified point.
x | The x-component of the vector |
y | The y-component of the vector |
z | The z-component of the vector |
|
inlineconstexpr |
Construct a vector by copying the specified vector.
U | Type of the vector to copy |
rhs | Vector to copy |
|
inline |
Computes the angle between the specified vector and the current vector.
U | Type of the components of the vector to compute angle with |
rhs | Vector to compute angle with |
|
inline |
Computes the complex conjugate of the vector.
|
inline |
Overwrites the vector with its complex conjugate.
|
inlineconstexpr |
Computes the cross product of this vector with the specified vector.
U | Type of the components of the vector to cross product with |
rhs | Vector to cross product with this vector |
|
inlineconstexpr |
Computes the dot product of this vector with the specified vector.
U | Type of the components of the vector to dot product with |
rhs | Vector to dot product with this vector |
|
inlineconstexpr |
Computes the length of the vector.
|
inlineconstexpr |
Gets the square of the length of the vector.
|
inlineconstexpr |
Normalises the current vector.
|
inlineconstexpr |
Gets a new vector which is the normalised version of this vector.
|
inlineconstexpr |
Performs elementwise multiplication of all components of this vector by the other vector.
U | Type of the components of the vector to multiply by |
rhs | Vector to multiply by elementwise |
|
inlineconstexpr |
Multiplies all components of this vector by a constant.
U | Type of right hand side |
rhs | Constant to multiple vector by |
|
inlineconstexpr |
Adds another 3D vector to this vector.
U | Type of the components of the vector to add |
rhs | Vector to add |
|
inlineconstexpr |
Adds a scalar to this vector.
rhs | Scalar value to add |
|
inlineconstexpr |
Returns the negated vector.
rhs | Vector to negate |
|
inlineconstexpr |
Subtracts another 3D vector to this vector.
U | Type of the components of the vector to subtract |
rhs | Vector to subtract |
|
inlineconstexpr |
Subtracts a scalar from this vector.
rhs | Scalar value to subtract |
|
inlineconstexpr |
Performs elementwise division of all components of this vector by the other vector.
U | Type of the components of the vector to divide by |
rhs | Vector to divide by elementwise |
|
inlineconstexpr |
Divides all components of this vector by a constant.
U | Type of right hand side |
rhs | Constant to divide vector by |
|
inlineconstexpr |
Copy the specified vector to this.
U | Type of the vector to copy |
rhs | Vector to copy |
|
inlineconstexpr |
Set all components tof vector equal to a constants.
rhs | Scalar to set vector to |
|
inlineconstexpr |
Gets a mutable reference to the component of the vector by index.
i | The index of the component of the vector to get (must be 0, 1, or 2). |
std::out_of_range | If i is not 0, 1, or 2. |
|
inlineconstexpr |
Gets a component of the vector by index.
i | The index of the component of the vector to get (must be 0, 1, or 2). |
std::out_of_range | If i is not 0, 1, or 2. |
|
inline |
Gets the number of elements in the vector.
|
inline |
Swizzle function to get 2D vector containing x & y components.
|
inline |
Swizzle function to get 2D vector containing x & z components.
|
inline |
Swizzle function to get 2D vector containing y & z components.
T ptems::BasicVector< T, 3 >::X |
The x-component of the vector.
T ptems::BasicVector< T, 3 >::Y |
The y-component of the vector.
T ptems::BasicVector< T, 3 >::Z |
The z-component of the vector.