Vector representing a point in two-dimensional space. More...
#include <ptems/vector.hpp>
Public Types | |
using | ConjugateType = BasicVector< typename std::conditional_t< is_complex_v< T >, T, std::complex< T > >, 2 > |
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... | |
template<typename U > | |
constexpr | BasicVector (const BasicVector< U, 2 > rhs) |
Construct a vector by copying the specified vector. More... | |
template<typename U > | |
constexpr BasicVector & | operator= (const BasicVector< U, 2 > rhs) |
Copy the specified vector to this. More... | |
constexpr BasicVector & | operator= (T rhs) |
Set all components tof vector equal to a constants. More... | |
constexpr | BasicVector (T x, T y) |
Construct a vector for the specified point. More... | |
template<typename U > | |
constexpr BasicVector & | operator+= (const BasicVector< U, 2 > &rhs) |
Adds another 2D 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, 2 > &rhs) |
Subtracts another 2D 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, 2 > &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, 2 > &rhs) |
Performs elementwise multiplication of all components of this vector by the other vector. More... | |
constexpr BasicVector | operator- () const |
Returns the negated vector. More... | |
constexpr BasicVector & | RotateCW90 () |
Rotates the current vector clockwise by 90 degrees. More... | |
constexpr BasicVector & | RotateCCW90 () |
Rotates the current vector counter-clockwise by 90 degrees. More... | |
BasicVector & | RotateCCW (remove_complex_t< T > angle) |
Rotates the current vector counter-clockwise by the specified angle in radians. More... | |
BasicVector & | RotateCW (remove_complex_t< T > angle) |
Rotates the current vector clockwise by the specified angle in radians. More... | |
constexpr BasicVector | RotatedCW90 () const |
Computes a vector which is the current vector rotated clockwise by 90 degrees. More... | |
constexpr BasicVector | RotatedCCW90 () const |
Computes a vector which is the current vector rotated counter-clockwise by 90 degrees. More... | |
BasicVector | RotatedCCW (remove_complex_t< T > angle) const |
Computes a vector which is the current vector counter-clockwise by the specified angle in radians. More... | |
BasicVector | RotatedCW (remove_complex_t< T > angle) const |
Computes a vector which is the current vector clockwise by the specified angle in radians. More... | |
template<typename U > | |
constexpr std::common_type_t< T, U > | Dot (const BasicVector< U, 2 > &rhs) const |
Computes the dot 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 > | |
std::common_type_t< T, U > | Wedge (const BasicVector< U, 2 > &rhs) const |
Computes the wedge product of two vectors. 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, 2 > &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... | |
Vector representing a point in two-dimensional space.
using ptems::BasicVector< T, 2 >::ConjugateType = BasicVector<typename std::conditional_t<is_complex_v<T>, T, std::complex<T> >,2> |
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 by copying the specified vector.
U | Type of the vector to copy |
rhs | Vector to copy |
|
inlineconstexpr |
Construct a vector for the specified point.
x | The x-component of the vector |
y | The y-component of the vector |
|
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 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 2D 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 2D 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 or 1). |
std::out_of_range | If i is not 0 or 1. |
|
inlineconstexpr |
Gets a component of the vector by index.
i | The index of the component of the vector to get (must be 0 or 1). |
std::out_of_range | If i is not 0 or 1. |
|
inline |
Rotates the current vector counter-clockwise by the specified angle in radians.
angle | Angle to rotate by |
|
inlineconstexpr |
Rotates the current vector counter-clockwise by 90 degrees.
|
inline |
Rotates the current vector clockwise by the specified angle in radians.
angle | Angle to rotate by |
|
inlineconstexpr |
Rotates the current vector clockwise by 90 degrees.
|
inline |
Computes a vector which is the current vector counter-clockwise by the specified angle in radians.
angle | Angle to rotate by |
|
inlineconstexpr |
Computes a vector which is the current vector rotated counter-clockwise by 90 degrees.
|
inline |
Computes a vector which is the current vector clockwise by the specified angle in radians.
angle | Angle to rotate by |
|
inlineconstexpr |
Computes a vector which is the current vector rotated clockwise by 90 degrees.
|
inline |
Gets the number of elements in the vector.
|
inline |
Computes the wedge product of two vectors.
U | Type of the components of the vector to wedge product with |
rhs | Vector to compute wedge with |
T ptems::BasicVector< T, 2 >::X |
The x-component of the vector.
T ptems::BasicVector< T, 2 >::Y |
The y-component of the vector.