EBGeometry  1.0
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
Vec3T< T > Class Template Reference

Three-dimensional vector class with arithmetic operators. More...

#include <EBGeometry_Vec.hpp>

Public Member Functions

 Vec3T () noexcept
 Default constructor. Sets the vector to the zero vector.
 
 Vec3T (const Vec3T< T > &a_u) noexcept
 Copy constructor. More...
 
constexpr Vec3T (const T &a_x, const T &a_y, const T &a_z) noexcept
 Full constructor. More...
 
 ~Vec3T () noexcept=default
 Destructor (does nothing)
 
constexpr bool lessLX (const Vec3T< T > &u) const noexcept
 Lexicographical comparison operator. This returns to true. More...
 
constexpr T & operator[] (size_t i) noexcept
 Return component in vector. (i=0 => x and so on) More...
 
constexpr const T & operator[] (size_t i) const noexcept
 Return non-modifiable component in vector. (i=0 => x and so on) More...
 
constexpr bool operator== (const Vec3T< T > &u) const noexcept
 Comparison operator. Returns true if all components are the same. More...
 
constexpr bool operator!= (const Vec3T< T > &u) const noexcept
 Comparison operator. Returns false if all components are the same. More...
 
constexpr bool operator< (const Vec3T< T > &u) const noexcept
 "Smaller than" operator. More...
 
constexpr bool operator> (const Vec3T< T > &u) const noexcept
 "Greater than" operator. More...
 
constexpr bool operator<= (const Vec3T< T > &u) const noexcept
 "Smaller or equal to" operator. More...
 
constexpr bool operator>= (const Vec3T< T > &u) const noexcept
 "Greater or equal to" operator. More...
 
constexpr Vec3T< T > & operator= (const Vec3T< T > &u) noexcept
 Assignment operator. Sets components equal to the argument vector's components. More...
 
constexpr Vec3T< T > operator+ (const Vec3T< T > &u) const noexcept
 Addition operator. Returns a new vector with added components. More...
 
constexpr Vec3T< T > operator- (const Vec3T< T > &u) const noexcept
 Subtraction operator. Returns a new vector with subtracted components. More...
 
constexpr Vec3T< T > operator- () const noexcept
 Negation operator. Returns a vector with negated components.
 
constexpr Vec3T< T > operator* (const T &s) const noexcept
 Multiplication operator. Returns a vector with scalar multiplied components. More...
 
constexpr Vec3T< T > operator* (const Vec3T< T > &s) const noexcept
 Component-wise multiplication operator. More...
 
constexpr Vec3T< T > operator/ (const T &s) const noexcept
 Division operator. Returns a vector with scalar divided components. More...
 
constexpr Vec3T< T > operator/ (const Vec3T< T > &v) const noexcept
 Component-wise division operator. More...
 
constexpr Vec3T< T > & operator+= (const Vec3T< T > &u) noexcept
 Vector addition operator. More...
 
constexpr Vec3T< T > & operator-= (const Vec3T< T > &u) noexcept
 Vector subtraction operator. More...
 
constexpr Vec3T< T > & operator*= (const T &s) noexcept
 Vector multiplication operator. More...
 
constexpr Vec3T< T > & operator/= (const T &s) noexcept
 Vector division operator. More...
 
constexpr Vec3T< T > min (const Vec3T< T > &u) noexcept
 Vector minimum function. Returns a new vector with componentwise minimums. More...
 
constexpr Vec3T< T > max (const Vec3T< T > &u) noexcept
 Vector maximum function. Returns a new vector with componentwise maximums. More...
 
constexpr Vec3T< T > cross (const Vec3T< T > &u) const noexcept
 Vector cross product. More...
 
constexpr T dot (const Vec3T< T > &u) const noexcept
 Vector dot product. More...
 
size_t minDir (const bool a_doAbs) const noexcept
 Return the direction which has the smallest component (can be absolute) More...
 
size_t maxDir (const bool a_doAbs) const noexcept
 Return the direction which has the largest component (can be absolute) More...
 
constexpr T length () const noexcept
 Compute vector length. More...
 
constexpr T length2 () const noexcept
 Compute vector length squared. More...
 

Static Public Member Functions

static constexpr Vec3T< T > zero () noexcept
 Return av vector with x = y = z = 0.
 
static constexpr Vec3T< T > one () noexcept
 Return av vector with x = y = z = 1.
 
static constexpr Vec3T< T > unit (const size_t a_dir) noexcept
 Return av vector with x = y = z = 1. More...
 
static constexpr Vec3T< T > min () noexcept
 Return a vector with minimum representable components.
 
static constexpr Vec3T< T > max () noexcept
 Return a vector with maximum representable components.
 
static constexpr Vec3T< T > infinity () noexcept
 Return a vector with inf components.
 

Protected Attributes

std::array< T, 3 > m_X
 Vector components.
 

Friends

std::ostream & operator<< (std::ostream &os, const Vec3T< T > &vec)
 For outputting a vector to an output stream.
 

Detailed Description

template<typename T>
class Vec3T< T >

Three-dimensional vector class with arithmetic operators.

The class has a public-only interface. To change it's components one can call the member functions, or set components directly, e.g. vec.x = 5.0

Note
Vec3T is a templated class primarily used with DCEL grids. It is always 3D, i.e. independent of Chombo configuration settings. This lets one use DCEL functionality even though the simulation might only be 2D.

Constructor & Destructor Documentation

◆ Vec3T() [1/2]

template<typename T >
Vec3T< T >::Vec3T ( const Vec3T< T > &  a_u)
noexcept

Copy constructor.

Parameters
[in]a_uOther vector

Sets *this = u

◆ Vec3T() [2/2]

template<typename T >
constexpr Vec3T< T >::Vec3T ( const T &  a_x,
const T &  a_y,
const T &  a_z 
)
constexprnoexcept

Full constructor.

Parameters
[in]a_xFirst vector component
[in]a_ySecond vector component
[in]a_zThird vector component

Sets this->x = a_x, this->y = a_y, and this->z = a_z

Member Function Documentation

◆ cross()

template<typename T >
constexpr Vec3T<T> Vec3T< T >::cross ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Vector cross product.

Parameters
[in]uOther vector
Returns
Returns the cross product between (*this) and u

◆ dot()

template<typename T >
constexpr T Vec3T< T >::dot ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Vector dot product.

Parameters
[in]uOther vector
Returns
Returns the dot product between (*this) and u

◆ length()

template<typename T >
constexpr T Vec3T< T >::length ( ) const
inlineconstexprnoexcept

Compute vector length.

Returns
Returns the vector length, i.e. sqrt(X[0]*X[0] + X[1]*X[1] + Y[0]*Y[0])

◆ length2()

template<typename T >
constexpr T Vec3T< T >::length2 ( ) const
inlineconstexprnoexcept

Compute vector length squared.

Returns
Returns the vector length squared, i.e. (X[0]*X[0] + X[1]*X[1] + Y[0]*Y[0])

◆ lessLX()

template<typename T >
constexpr bool Vec3T< T >::lessLX ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Lexicographical comparison operator. This returns to true.

Parameters
[in]uOther vector.

◆ max()

template<typename T >
constexpr Vec3T<T> Vec3T< T >::max ( const Vec3T< T > &  u)
inlineconstexprnoexcept

Vector maximum function. Returns a new vector with componentwise maximums.

Parameters
[in]uOther vector
Returns
Returns a new vector with X[0] = std::minmax->X[0], u.X[0]) (and same for the other components)

◆ maxDir()

template<typename T >
size_t Vec3T< T >::maxDir ( const bool  a_doAbs) const
inlinenoexcept

Return the direction which has the largest component (can be absolute)

Parameters
[in]a_doAbsIf true, evaluate component magnitudes rather than values.
Returns
Direction with the biggest component

◆ min()

template<typename T >
constexpr Vec3T<T> Vec3T< T >::min ( const Vec3T< T > &  u)
inlineconstexprnoexcept

Vector minimum function. Returns a new vector with componentwise minimums.

Parameters
[in]uOther vector
Returns
Returns a new vector with X[0] = std::min(this->X[0], u.X[0]) (and same for the other components)

◆ minDir()

template<typename T >
size_t Vec3T< T >::minDir ( const bool  a_doAbs) const
inlinenoexcept

Return the direction which has the smallest component (can be absolute)

Parameters
[in]a_doAbsIf true, evaluate component magnitudes rather than values.
Returns
Direction with the biggest component

◆ operator!=()

template<typename T >
constexpr bool Vec3T< T >::operator!= ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Comparison operator. Returns false if all components are the same.

Parameters
[in]uOther vector

◆ operator*() [1/2]

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator* ( const T &  s) const
inlineconstexprnoexcept

Multiplication operator. Returns a vector with scalar multiplied components.

Parameters
[in]sScalar to multiply by
Returns
Returns a new vector with X[i] = this->X[i] * s

◆ operator*() [2/2]

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator* ( const Vec3T< T > &  s) const
inlineconstexprnoexcept

Component-wise multiplication operator.

Parameters
[in]sScalar to multiply by
Returns
Returns a new vector with X[i] = this->X[i] * s[i] for each component.

◆ operator*=()

template<typename T >
constexpr Vec3T<T>& Vec3T< T >::operator*= ( const T &  s)
inlineconstexprnoexcept

Vector multiplication operator.

Parameters
[in]sScalar to multiply by
Returns
Returns (*this) with multiplied components, e.g. this->X[0] = this->X[0] * s

◆ operator+()

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator+ ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Addition operator. Returns a new vector with added components.

Returns
Returns a new vector with x = this->x - u.x and so on.
Parameters
[in]uOther vector

◆ operator+=()

template<typename T >
constexpr Vec3T<T>& Vec3T< T >::operator+= ( const Vec3T< T > &  u)
inlineconstexprnoexcept

Vector addition operator.

Parameters
[in]uVector to add
Returns
Returns (*this) with incremented components, e.g. this->X[0] = this->X[0] + u.X[0]

◆ operator-()

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator- ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Subtraction operator. Returns a new vector with subtracted components.

Returns
Returns a new vector with x = this->x - u.x and so on.
Parameters
[in]uOther vector

◆ operator-=()

template<typename T >
constexpr Vec3T<T>& Vec3T< T >::operator-= ( const Vec3T< T > &  u)
inlineconstexprnoexcept

Vector subtraction operator.

Parameters
[in]uVector to subtraction
Returns
Returns (*this) with subtracted components, e.g. this->X[0] = this->X[0] - u.X[0]

◆ operator/() [1/2]

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator/ ( const T &  s) const
inlineconstexprnoexcept

Division operator. Returns a vector with scalar divided components.

Parameters
[in]sScalar to divided by
Returns
Returns a new vector with X[i] = this->X[i] / s

◆ operator/() [2/2]

template<typename T >
constexpr Vec3T<T> Vec3T< T >::operator/ ( const Vec3T< T > &  v) const
inlineconstexprnoexcept

Component-wise division operator.

Parameters
[in]vOther vector
Returns
Returns a new vector with X[i] = this->X[i]/v[i] for each component.

◆ operator/=()

template<typename T >
constexpr Vec3T<T>& Vec3T< T >::operator/= ( const T &  s)
inlineconstexprnoexcept

Vector division operator.

Parameters
[in]sScalar to divide by
Returns
Returns (*this) with multiplied components, e.g. this->X[0] = this->X[0] / s

◆ operator<()

template<typename T >
constexpr bool Vec3T< T >::operator< ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

"Smaller than" operator.

Returns true if this->x < u.x AND this->y < u.y AND this->z < u.z and false otherwise

Parameters
[in]uOther vector

◆ operator<=()

template<typename T >
constexpr bool Vec3T< T >::operator<= ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

"Smaller or equal to" operator.

Returns true if this->x <= u.x AND this->y <= u.y AND this->z <= u.z

Parameters
[in]uOther vector

◆ operator=()

template<typename T >
constexpr Vec3T<T>& Vec3T< T >::operator= ( const Vec3T< T > &  u)
inlineconstexprnoexcept

Assignment operator. Sets components equal to the argument vector's components.

Parameters
[in]uOther vector

◆ operator==()

template<typename T >
constexpr bool Vec3T< T >::operator== ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

Comparison operator. Returns true if all components are the same.

Parameters
[in]uOther vector

◆ operator>()

template<typename T >
constexpr bool Vec3T< T >::operator> ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

"Greater than" operator.

Returns true if this->x > u.x AND this->y > u.y AND this->z > u.z

Parameters
[in]uOther vector

◆ operator>=()

template<typename T >
constexpr bool Vec3T< T >::operator>= ( const Vec3T< T > &  u) const
inlineconstexprnoexcept

"Greater or equal to" operator.

Returns true if this->x >= u.x AND this->y >= u.y AND this->z >= u.z

Parameters
[in]uOther vector

◆ operator[]() [1/2]

template<typename T >
constexpr const T& Vec3T< T >::operator[] ( size_t  i) const
inlineconstexprnoexcept

Return non-modifiable component in vector. (i=0 => x and so on)

Parameters
[in]iIndex. Must be < 3

◆ operator[]() [2/2]

template<typename T >
constexpr T& Vec3T< T >::operator[] ( size_t  i)
inlineconstexprnoexcept

Return component in vector. (i=0 => x and so on)

Parameters
[in]iIndex. Must be < 3

◆ unit()

template<typename T >
static constexpr Vec3T<T> Vec3T< T >::unit ( const size_t  a_dir)
inlinestaticconstexprnoexcept

Return av vector with x = y = z = 1.

Parameters
[in]a_dirDircetion

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