PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::BasicVector< T, 3 > Struct Template Reference

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 BasicVectoroperator= (const BasicVector< U, 3 > rhs)
 Copy the specified vector to this. More...
 
constexpr BasicVectoroperator= (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 BasicVectoroperator+= (const BasicVector< U, 3 > &rhs)
 Adds another 3D vector to this vector. More...
 
constexpr BasicVectoroperator+= (T rhs)
 Adds a scalar to this vector. More...
 
template<typename U >
constexpr BasicVectoroperator-= (const BasicVector< U, 3 > &rhs)
 Subtracts another 3D vector to this vector. More...
 
constexpr BasicVectoroperator-= (T rhs)
 Subtracts a scalar from this vector. More...
 
template<typename U >
constexpr BasicVectoroperator/= (U rhs)
 Divides all components of this vector by a constant. More...
 
template<typename U >
constexpr BasicVectoroperator/= (const BasicVector< U, 3 > &rhs)
 Performs elementwise division of all components of this vector by the other vector. More...
 
template<typename U >
constexpr BasicVectoroperator*= (U rhs)
 Multiplies all components of this vector by a constant. More...
 
template<typename U >
constexpr BasicVectoroperator*= (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 BasicVectorNormalise ()
 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...
 
BasicVectorConjugateOverwrite () 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

X
 The x-component of the vector. More...
 
Y
 The y-component of the vector. More...
 
Z
 The z-component of the vector. More...
 

Detailed Description

template<typename T>
struct ptems::BasicVector< T, 3 >

Vector representing a point in three-dimensional space.

Member Typedef Documentation

◆ ConjugateType

template<typename T >
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>.

Constructor & Destructor Documentation

◆ BasicVector() [1/4]

template<typename T >
constexpr ptems::BasicVector< T, 3 >::BasicVector ( )
inlineconstexpr

Construct a zero vector.

◆ BasicVector() [2/4]

template<typename T >
constexpr ptems::BasicVector< T, 3 >::BasicVector ( value)
inlineexplicitconstexpr

Construct a vector with all components equal to the specified value.

Parameters
valueValue to fill in each component of the vector

◆ BasicVector() [3/4]

template<typename T >
constexpr ptems::BasicVector< T, 3 >::BasicVector ( x,
y,
z 
)
inlineconstexpr

Construct a vector for the specified point.

Parameters
xThe x-component of the vector
yThe y-component of the vector
zThe z-component of the vector

◆ BasicVector() [4/4]

template<typename T >
template<typename U >
constexpr ptems::BasicVector< T, 3 >::BasicVector ( const BasicVector< U, 3 >  rhs)
inlineconstexpr

Construct a vector by copying the specified vector.

Template Parameters
UType of the vector to copy
Parameters
rhsVector to copy

Member Function Documentation

◆ Angle()

template<typename T >
template<typename U , typename = std::enable_if_t<!is_complex_v<T> && !is_complex_v<U>>>
std::common_type_t<T,U> ptems::BasicVector< T, 3 >::Angle ( const BasicVector< U, 3 > &  rhs) const
inline

Computes the angle between the specified vector and the current vector.

Warning
This method may not make sense for vectors of complex numbers
Template Parameters
UType of the components of the vector to compute angle with
Parameters
rhsVector to compute angle with
Returns
Angle, in the range \( [0,\pi] \), to rotate this vector by (counter-clockwise) around the axis determined by the cross product to get the rhs vector.

◆ Conjugate()

template<typename T >
ConjugateType ptems::BasicVector< T, 3 >::Conjugate ( ) const
inline

Computes the complex conjugate of the vector.

Returns
The complex conjugate of the vector

◆ ConjugateOverwrite()

template<typename T >
BasicVector& ptems::BasicVector< T, 3 >::ConjugateOverwrite ( ) const
inline

Overwrites the vector with its complex conjugate.

Returns
this

◆ Cross()

template<typename T >
template<typename U >
constexpr BasicVector<std::common_type_t<T,U>,3> ptems::BasicVector< T, 3 >::Cross ( const BasicVector< U, 3 > &  rhs) const
inlineconstexpr

Computes the cross product of this vector with the specified vector.

Warning
This method may not make sense for vectors of complex numbers
Template Parameters
UType of the components of the vector to cross product with
Parameters
rhsVector to cross product with this vector
Returns
The vector result of the cross product

◆ Dot()

template<typename T >
template<typename U >
constexpr std::common_type_t<T,U> ptems::BasicVector< T, 3 >::Dot ( const BasicVector< U, 3 > &  rhs) const
inlineconstexpr

Computes the dot product of this vector with the specified vector.

Template Parameters
UType of the components of the vector to dot product with
Parameters
rhsVector to dot product with this vector
Returns
The result of the dot product

◆ Length()

template<typename T >
constexpr remove_complex_t<T> ptems::BasicVector< T, 3 >::Length ( ) const
inlineconstexpr

Computes the length of the vector.

Returns
The vector length.

◆ LengthSquared()

template<typename T >
constexpr remove_complex_t<T> ptems::BasicVector< T, 3 >::LengthSquared ( ) const
inlineconstexpr

Gets the square of the length of the vector.

Returns
The length squared.

◆ Normalise()

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 3 >::Normalise ( )
inlineconstexpr

Normalises the current vector.

Returns
Reference to this vector after normalisation.

◆ Normalised()

template<typename T >
constexpr BasicVector ptems::BasicVector< T, 3 >::Normalised ( ) const
inlineconstexpr

Gets a new vector which is the normalised version of this vector.

Returns
The normalised vector

◆ operator*=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator*= ( const BasicVector< U, 3 > &  rhs)
inlineconstexpr

Performs elementwise multiplication of all components of this vector by the other vector.

Template Parameters
UType of the components of the vector to multiply by
Parameters
rhsVector to multiply by elementwise
Returns
Reference to this vector after multiplying by rhs

◆ operator*=() [2/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator*= ( rhs)
inlineconstexpr

Multiplies all components of this vector by a constant.

Template Parameters
UType of right hand side
Parameters
rhsConstant to multiple vector by
Returns
Reference to this vector after multiplying by rhs

◆ operator+=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator+= ( const BasicVector< U, 3 > &  rhs)
inlineconstexpr

Adds another 3D vector to this vector.

Template Parameters
UType of the components of the vector to add
Parameters
rhsVector to add
Returns
Reference to this vector after adding rhs

◆ operator+=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator+= ( rhs)
inlineconstexpr

Adds a scalar to this vector.

Parameters
rhsScalar value to add
Returns
Reference to this vector after adding rhs

◆ operator-()

template<typename T >
constexpr BasicVector ptems::BasicVector< T, 3 >::operator- ( ) const
inlineconstexpr

Returns the negated vector.

Parameters
rhsVector to negate
Returns
The negated vector

◆ operator-=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator-= ( const BasicVector< U, 3 > &  rhs)
inlineconstexpr

Subtracts another 3D vector to this vector.

Template Parameters
UType of the components of the vector to subtract
Parameters
rhsVector to subtract
Returns
Reference to this vector after subtracting rhs

◆ operator-=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator-= ( rhs)
inlineconstexpr

Subtracts a scalar from this vector.

Parameters
rhsScalar value to subtract
Returns
Reference to this vector after subtracting rhs

◆ operator/=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator/= ( const BasicVector< U, 3 > &  rhs)
inlineconstexpr

Performs elementwise division of all components of this vector by the other vector.

Template Parameters
UType of the components of the vector to divide by
Parameters
rhsVector to divide by elementwise
Returns
Reference to this vector after dividing by rhs

◆ operator/=() [2/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator/= ( rhs)
inlineconstexpr

Divides all components of this vector by a constant.

Template Parameters
UType of right hand side
Parameters
rhsConstant to divide vector by
Returns
Reference to this vector after dividing by rhs

◆ operator=() [1/2]

template<typename T >
template<typename U >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator= ( const BasicVector< U, 3 >  rhs)
inlineconstexpr

Copy the specified vector to this.

Template Parameters
UType of the vector to copy
Parameters
rhsVector to copy

◆ operator=() [2/2]

template<typename T >
constexpr BasicVector& ptems::BasicVector< T, 3 >::operator= ( rhs)
inlineconstexpr

Set all components tof vector equal to a constants.

Parameters
rhsScalar to set vector to

◆ operator[]() [1/2]

template<typename T >
constexpr T& ptems::BasicVector< T, 3 >::operator[] ( std::size_t  i)
inlineconstexpr

Gets a mutable reference to the component of the vector by index.

Parameters
iThe index of the component of the vector to get (must be 0, 1, or 2).
Exceptions
std::out_of_rangeIf i is not 0, 1, or 2.
Returns
Mutable reference to the value at the specified component

◆ operator[]() [2/2]

template<typename T >
constexpr T ptems::BasicVector< T, 3 >::operator[] ( std::size_t  i) const
inlineconstexpr

Gets a component of the vector by index.

Parameters
iThe index of the component of the vector to get (must be 0, 1, or 2).
Exceptions
std::out_of_rangeIf i is not 0, 1, or 2.
Returns
Value at the specified component

◆ size()

template<typename T >
std::size_t ptems::BasicVector< T, 3 >::size ( ) const
inline

Gets the number of elements in the vector.

Returns
3

◆ XY()

template<typename T >
BasicVector<T, 2> ptems::BasicVector< T, 3 >::XY ( ) const
inline

Swizzle function to get 2D vector containing x & y components.

Returns
2D vector containing X and Y components

◆ XZ()

template<typename T >
BasicVector<T, 2> ptems::BasicVector< T, 3 >::XZ ( ) const
inline

Swizzle function to get 2D vector containing x & z components.

Returns
2D vector containing X and Z components

◆ YZ()

template<typename T >
BasicVector<T, 2> ptems::BasicVector< T, 3 >::YZ ( ) const
inline

Swizzle function to get 2D vector containing y & z components.

Returns
2D vector containing Y and Z components

Member Data Documentation

◆ X

template<typename T >
T ptems::BasicVector< T, 3 >::X

The x-component of the vector.

◆ Y

template<typename T >
T ptems::BasicVector< T, 3 >::Y

The y-component of the vector.

◆ Z

template<typename T >
T ptems::BasicVector< T, 3 >::Z

The z-component of the vector.


The documentation for this struct was generated from the following file: