PLaSK library
Loading...
Searching...
No Matches
plask::Vec< 3, T > Struct Template Reference

Vector in 3D space. More...

#include <plask/vector/3d.hpp>

Collaboration diagram for plask::Vec< 3, T >:
[legend]

Public Types

typedef T * iterator
 Type of iterator over components.
 
typedef const T * const_iterator
 Type of const iterator over components.
 

Public Member Functions

T & lon ()
 
constexpr const T & lon () const
 
T & tran ()
 
constexpr const T & tran () const
 
T & vert ()
 
constexpr const T & vert () const
 
T & rad_p ()
 
constexpr const T & rad_p () const
 
T & rad_r ()
 
constexpr const T & rad_r () const
 
T & rad_z ()
 
constexpr const T & rad_z () const
 
T & se_x ()
 
constexpr const T & se_x () const
 
T & se_y ()
 
constexpr const T & se_y () const
 
T & se_z ()
 
constexpr const T & se_z () const
 
T & zup_x ()
 
constexpr const T & z_up_x () const
 
T & zup_y ()
 
constexpr const T & z_up_y () const
 
T & zup_z ()
 
constexpr const T & z_up_z () const
 
T & ee_z ()
 
constexpr const T & ee_z () const
 
T & ee_x ()
 
constexpr const T & ee_x () const
 
T & ee_y ()
 
constexpr const T & ee_y () const
 
T & yup_z ()
 
constexpr const T & y_up_z () const
 
T & yup_x ()
 
constexpr const T & y_up_x () const
 
T & yup_y ()
 
constexpr const T & y_up_y () const
 
 Vec ()
 Construct uninitialized vector.
 
template<typename OtherT >
constexpr Vec (const Vec< 3, OtherT > &p)
 Copy constructor from all other 2D vectors.
 
constexpr Vec (const T &c0__lon, const T &c1__tran, const T &c2__up)
 Construct vector with given components.
 
template<typename T0 , typename T1 , typename T2 >
constexpr Vec (const std::tuple< T0, T1, T2 > &comp)
 Construct vector components given in std::tuple.
 
iterator begin ()
 Get begin iterator over components.
 
const_iterator begin () const
 Get begin const iterator over components.
 
iterator end ()
 Get end iterator over components.
 
const_iterator end () const
 Get end const iterator over components.
 
template<typename OtherT >
constexpr bool operator== (const Vec< 3, OtherT > &p) const
 Compare two vectors, this and p.
 
template<typename OtherT , typename SuprType >
constexpr bool equals (const Vec< 3, OtherT > &p, const SuprType &abs_supremum) const
 Check if two vectors, this and p are almost equal.
 
template<typename OtherT >
constexpr bool equals (const Vec< 3, OtherT > &p) const
 Check if two vectors, this and p are almost equal.
 
template<typename OtherT >
constexpr bool operator!= (const Vec< 3, OtherT > &p) const
 Compare two vectors, this and p.
 
T & operator[] (size_t i)
 Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)
 
const T & operator[] (size_t i) const
 Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)
 
template<typename OtherT >
constexpr auto operator+ (const Vec< 3, OtherT > &other) const -> Vec< 3, decltype(c0+other.c0)>
 Calculate sum of two vectors, this and other.
 
Vec< 3, T > & operator+= (const Vec< 3, T > &other)
 Increase coordinates of this vector by coordinates of other vector other.
 
template<typename OtherT >
constexpr auto operator- (const Vec< 3, OtherT > &other) const -> Vec< 3, decltype(c0 - other.c0)>
 Calculate difference of two vectors, this and other.
 
Vec< 3, T > & operator-= (const Vec< 3, T > &other)
 Decrease coordinates of this vector by coordinates of other vector other.
 
template<typename OtherT >
constexpr auto operator* (const OtherT scale) const -> Vec< 3, decltype(c0 *scale)>
 Calculate this vector multiplied by scalar scale.
 
Vec< 3, T > & operator*= (const T scalar)
 Multiple coordinates of this vector by scalar.
 
constexpr Vec< 3, T > operator/ (const T scalar) const
 Calculate this vector divided by scalar.
 
Vec< 3, T > & operator/= (const T scalar)
 Divide coordinates of this vector by scalar.
 
constexpr Vec< 3, T > operator- () const
 Calculate vector opposite to this.
 
Vec< 3, T > sqr () const
 Square each component of tensor.
 
Vec< 3, T > & sqr_inplace ()
 Square each component of tensor in place.
 
Vec< 3, T > sqrt () const
 Square root of each component of tensor.
 
Vec< 3, T > & sqrt_inplace ()
 Square root of each component of tensor in place.
 
template<typename OtherT >
Vec< 3, T > pow (OtherT a) const
 Power of each component of tensor.
 
void flip (size_t i)
 Change i-th coordinate to oposite.
 
Vec< 3, T > flipped (size_t i)
 Get vector similar to this but with changed i-th component to oposite.
 
template<class OT >
bool operator< (Vec< 3, OT > const &v) const
 A lexical comparison of two vectors, allow to use vector in std::set and std::map as key type.
 

Static Public Member Functions

template<typename InputIteratorType >
static Vec< 3, T > fromIterator (InputIteratorType inputIt)
 Construct vector with components read from input iterator (including C array).
 

Public Attributes

c0
 Vector components.
 
c1
 
c2
 

Static Public Attributes

static const int DIMS = 3
 

Friends

std::ostream & operator<< (std::ostream &out, const Vec< 3, T > &to_print)
 Print vector to stream using format (where c0, c1 and c2 are vector coordinates): [c0, c1, c2].
 

Detailed Description

template<typename T>
struct plask::Vec< 3, T >

Vector in 3D space.

Definition at line 37 of file 3d.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const T* plask::Vec< 3, T >::const_iterator

Type of const iterator over components.

Definition at line 111 of file 3d.hpp.

◆ iterator

template<typename T >
typedef T* plask::Vec< 3, T >::iterator

Type of iterator over components.

Definition at line 106 of file 3d.hpp.

Constructor & Destructor Documentation

◆ Vec() [1/4]

template<typename T >
plask::Vec< 3, T >::Vec ( )
inline

Construct uninitialized vector.

Definition at line 114 of file 3d.hpp.

◆ Vec() [2/4]

template<typename T >
template<typename OtherT >
constexpr plask::Vec< 3, T >::Vec ( const Vec< 3, OtherT > &  p)
inlineconstexpr

Copy constructor from all other 2D vectors.

Parameters
pvector to copy from

Definition at line 121 of file 3d.hpp.

◆ Vec() [3/4]

template<typename T >
constexpr plask::Vec< 3, T >::Vec ( const T &  c0__lon,
const T &  c1__tran,
const T &  c2__up 
)
inlineconstexpr

Construct vector with given components.

Parameters
c0__lon,c1__tran,c2__upcomponents

Definition at line 127 of file 3d.hpp.

◆ Vec() [4/4]

template<typename T >
template<typename T0 , typename T1 , typename T2 >
constexpr plask::Vec< 3, T >::Vec ( const std::tuple< T0, T1, T2 > &  comp)
inlineconstexpr

Construct vector components given in std::tuple.

Parameters
compcomponents

Definition at line 134 of file 3d.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
iterator plask::Vec< 3, T >::begin ( )
inline

Get begin iterator over components.

Returns
begin iterator over components

Definition at line 154 of file 3d.hpp.

◆ begin() [2/2]

template<typename T >
const_iterator plask::Vec< 3, T >::begin ( ) const
inline

Get begin const iterator over components.

Returns
begin const iterator over components

Definition at line 160 of file 3d.hpp.

◆ ee_x() [1/2]

template<typename T >
T & plask::Vec< 3, T >::ee_x ( )
inline

Definition at line 87 of file 3d.hpp.

◆ ee_x() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::ee_x ( ) const
inlineconstexpr

Definition at line 88 of file 3d.hpp.

◆ ee_y() [1/2]

template<typename T >
T & plask::Vec< 3, T >::ee_y ( )
inline

Definition at line 90 of file 3d.hpp.

◆ ee_y() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::ee_y ( ) const
inlineconstexpr

Definition at line 91 of file 3d.hpp.

◆ ee_z() [1/2]

template<typename T >
T & plask::Vec< 3, T >::ee_z ( )
inline

Definition at line 84 of file 3d.hpp.

◆ ee_z() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::ee_z ( ) const
inlineconstexpr

Definition at line 85 of file 3d.hpp.

◆ end() [1/2]

template<typename T >
iterator plask::Vec< 3, T >::end ( )
inline

Get end iterator over components.

Returns
end iterator over components

Definition at line 166 of file 3d.hpp.

◆ end() [2/2]

template<typename T >
const_iterator plask::Vec< 3, T >::end ( ) const
inline

Get end const iterator over components.

Returns
end const iterator over components

Definition at line 172 of file 3d.hpp.

◆ equals() [1/2]

template<typename T >
template<typename OtherT >
constexpr bool plask::Vec< 3, T >::equals ( const Vec< 3, OtherT > &  p) const
inlineconstexpr

Check if two vectors, this and p are almost equal.

Parameters
pvector to compare
Returns
true only if this vector and p have almost equals coordinates

Definition at line 198 of file 3d.hpp.

◆ equals() [2/2]

template<typename T >
constexpr bool plask::Vec< 3, T >::equals ( const Vec< 3, OtherT > &  p,
const SuprType abs_supremum 
) const
inlineconstexpr

Check if two vectors, this and p are almost equal.

Parameters
pvector to compare
abs_supremummaximal allowed difference for one coordinate
Returns
true only if this vector and p have almost equals coordinates

Definition at line 189 of file 3d.hpp.

◆ flip()

template<typename T >
void plask::Vec< 3, T >::flip ( size_t  i)
inline

Change i-th coordinate to oposite.

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate

Definition at line 375 of file 3d.hpp.

◆ flipped()

template<typename T >
Vec< 3, T > plask::Vec< 3, T >::flipped ( size_t  i)
inline

Get vector similar to this but with changed i-th component to oposite.

WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
vector similar to this but with changed i-th component to oposite

Definition at line 386 of file 3d.hpp.

◆ fromIterator()

template<typename T >
static Vec< 3, T > plask::Vec< 3, T >::fromIterator ( InputIteratorType  inputIt)
inlinestatic

Construct vector with components read from input iterator (including C array).

Parameters
inputItinput iterator with minimum 3 objects available
Template Parameters
InputIteratorTypeinput iterator type, must allow for postincrementation and dereference operation

Definition at line 142 of file 3d.hpp.

◆ lon() [1/2]

template<typename T >
T & plask::Vec< 3, T >::lon ( )
inline

Definition at line 44 of file 3d.hpp.

◆ lon() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::lon ( ) const
inlineconstexpr

Definition at line 45 of file 3d.hpp.

◆ operator!=()

template<typename T >
template<typename OtherT >
constexpr bool plask::Vec< 3, T >::operator!= ( const Vec< 3, OtherT > &  p) const
inlineconstexpr

Compare two vectors, this and p.

Parameters
pvector to compare
Returns
true only if this vector and p don't have equals coordinates

Definition at line 208 of file 3d.hpp.

◆ operator*()

template<typename T >
template<typename OtherT >
constexpr auto plask::Vec< 3, T >::operator* ( const OtherT  scale) const -> Vec<3,decltype(c0*scale)>
inlineconstexpr

Calculate this vector multiplied by scalar scale.

Parameters
scalescalar
Returns
this vector multiplied by scalar

Definition at line 282 of file 3d.hpp.

◆ operator*=()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::operator*= ( const scalar)
inline

Multiple coordinates of this vector by scalar.

Parameters
scalarscalar
Returns
*this (after scale)

Definition at line 293 of file 3d.hpp.

◆ operator+()

template<typename T >
template<typename OtherT >
constexpr auto plask::Vec< 3, T >::operator+ ( const Vec< 3, OtherT > &  other) const -> Vec<3,decltype(c0 + other.c0)>
inlineconstexpr

Calculate sum of two vectors, this and other.

Parameters
othervector to add, can have different data type (than result type will be found using C++ types promotions rules)
Returns
vectors sum

Definition at line 238 of file 3d.hpp.

◆ operator+=()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::operator+= ( const Vec< 3, T > &  other)
inline

Increase coordinates of this vector by coordinates of other vector other.

Parameters
othervector to add
Returns
*this (after increase)

Definition at line 247 of file 3d.hpp.

◆ operator-() [1/2]

template<typename T >
constexpr Vec< 3, T > plask::Vec< 3, T >::operator- ( ) const
inlineconstexpr

Calculate vector opposite to this.

Returns
Vec<3,T>(-c0, -c1, -c2)

Definition at line 323 of file 3d.hpp.

◆ operator-() [2/2]

template<typename T >
template<typename OtherT >
constexpr auto plask::Vec< 3, T >::operator- ( const Vec< 3, OtherT > &  other) const -> Vec<3,decltype(c0 - other.c0)>
inlineconstexpr

Calculate difference of two vectors, this and other.

Parameters
othervector to subtract from this, can have different data type (than result type will be found using C++ types promotions rules)
Returns
vectors difference

Definition at line 260 of file 3d.hpp.

◆ operator-=()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::operator-= ( const Vec< 3, T > &  other)
inline

Decrease coordinates of this vector by coordinates of other vector other.

Parameters
othervector to subtract
Returns
*this (after decrease)

Definition at line 269 of file 3d.hpp.

◆ operator/()

template<typename T >
constexpr Vec< 3, T > plask::Vec< 3, T >::operator/ ( const scalar) const
inlineconstexpr

Calculate this vector divided by scalar.

Parameters
scalarscalar
Returns
this vector divided by scalar

Definition at line 305 of file 3d.hpp.

◆ operator/=()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::operator/= ( const scalar)
inline

Divide coordinates of this vector by scalar.

Parameters
scalarscalar
Returns
*this (after divide)

Definition at line 312 of file 3d.hpp.

◆ operator<()

template<typename T >
template<class OT >
bool plask::Vec< 3, T >::operator< ( Vec< 3, OT > const v) const
inline

A lexical comparison of two vectors, allow to use vector in std::set and std::map as key type.

It supports NaN-s (which, due to this method, is greater than all other numbers).

Parameters
vvectors to compare
Returns
true only if this is smaller than the v

Definition at line 410 of file 3d.hpp.

◆ operator==()

template<typename T >
template<typename OtherT >
constexpr bool plask::Vec< 3, T >::operator== ( const Vec< 3, OtherT > &  p) const
inlineconstexpr

Compare two vectors, this and p.

Parameters
pvector to compare
Returns
true only if this vector and p have equals coordinates

Definition at line 180 of file 3d.hpp.

◆ operator[]() [1/2]

template<typename T >
T & plask::Vec< 3, T >::operator[] ( size_t  i)
inline

Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
i-th component

Definition at line 216 of file 3d.hpp.

◆ operator[]() [2/2]

template<typename T >
const T & plask::Vec< 3, T >::operator[] ( size_t  i) const
inline

Get i-th component WARNING This function does not check if it is valid (for efficiency reasons)

Parameters
inumber of coordinate
Returns
i-th component

Definition at line 227 of file 3d.hpp.

◆ pow()

template<typename T >
template<typename OtherT >
Vec< 3, T > plask::Vec< 3, T >::pow ( OtherT  a) const
inline

Power of each component of tensor.

Returns
squared tensor

Definition at line 366 of file 3d.hpp.

◆ rad_p() [1/2]

template<typename T >
T & plask::Vec< 3, T >::rad_p ( )
inline

Definition at line 54 of file 3d.hpp.

◆ rad_p() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::rad_p ( ) const
inlineconstexpr

Definition at line 55 of file 3d.hpp.

◆ rad_r() [1/2]

template<typename T >
T & plask::Vec< 3, T >::rad_r ( )
inline

Definition at line 57 of file 3d.hpp.

◆ rad_r() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::rad_r ( ) const
inlineconstexpr

Definition at line 58 of file 3d.hpp.

◆ rad_z() [1/2]

template<typename T >
T & plask::Vec< 3, T >::rad_z ( )
inline

Definition at line 60 of file 3d.hpp.

◆ rad_z() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::rad_z ( ) const
inlineconstexpr

Definition at line 61 of file 3d.hpp.

◆ se_x() [1/2]

template<typename T >
T & plask::Vec< 3, T >::se_x ( )
inline

Definition at line 64 of file 3d.hpp.

◆ se_x() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::se_x ( ) const
inlineconstexpr

Definition at line 65 of file 3d.hpp.

◆ se_y() [1/2]

template<typename T >
T & plask::Vec< 3, T >::se_y ( )
inline

Definition at line 67 of file 3d.hpp.

◆ se_y() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::se_y ( ) const
inlineconstexpr

Definition at line 68 of file 3d.hpp.

◆ se_z() [1/2]

template<typename T >
T & plask::Vec< 3, T >::se_z ( )
inline

Definition at line 70 of file 3d.hpp.

◆ se_z() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::se_z ( ) const
inlineconstexpr

Definition at line 71 of file 3d.hpp.

◆ sqr()

template<typename T >
Vec< 3, T > plask::Vec< 3, T >::sqr ( ) const
inline

Square each component of tensor.

Returns
squared tensor

Definition at line 331 of file 3d.hpp.

◆ sqr_inplace()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::sqr_inplace ( )
inline

Square each component of tensor in place.

Returns
*this (squared)

Definition at line 339 of file 3d.hpp.

◆ sqrt()

template<typename T >
Vec< 3, T > plask::Vec< 3, T >::sqrt ( ) const
inline

Square root of each component of tensor.

Returns
squared tensor

Definition at line 348 of file 3d.hpp.

◆ sqrt_inplace()

template<typename T >
Vec< 3, T > & plask::Vec< 3, T >::sqrt_inplace ( )
inline

Square root of each component of tensor in place.

Returns
*this (squared)

Definition at line 356 of file 3d.hpp.

◆ tran() [1/2]

template<typename T >
T & plask::Vec< 3, T >::tran ( )
inline

Definition at line 47 of file 3d.hpp.

◆ tran() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::tran ( ) const
inlineconstexpr

Definition at line 48 of file 3d.hpp.

◆ vert() [1/2]

template<typename T >
T & plask::Vec< 3, T >::vert ( )
inline

Definition at line 50 of file 3d.hpp.

◆ vert() [2/2]

template<typename T >
constexpr const T & plask::Vec< 3, T >::vert ( ) const
inlineconstexpr

Definition at line 51 of file 3d.hpp.

◆ y_up_x()

template<typename T >
constexpr const T & plask::Vec< 3, T >::y_up_x ( ) const
inlineconstexpr

Definition at line 98 of file 3d.hpp.

◆ y_up_y()

template<typename T >
constexpr const T & plask::Vec< 3, T >::y_up_y ( ) const
inlineconstexpr

Definition at line 101 of file 3d.hpp.

◆ y_up_z()

template<typename T >
constexpr const T & plask::Vec< 3, T >::y_up_z ( ) const
inlineconstexpr

Definition at line 95 of file 3d.hpp.

◆ yup_x()

template<typename T >
T & plask::Vec< 3, T >::yup_x ( )
inline

Definition at line 97 of file 3d.hpp.

◆ yup_y()

template<typename T >
T & plask::Vec< 3, T >::yup_y ( )
inline

Definition at line 100 of file 3d.hpp.

◆ yup_z()

template<typename T >
T & plask::Vec< 3, T >::yup_z ( )
inline

Definition at line 94 of file 3d.hpp.

◆ z_up_x()

template<typename T >
constexpr const T & plask::Vec< 3, T >::z_up_x ( ) const
inlineconstexpr

Definition at line 75 of file 3d.hpp.

◆ z_up_y()

template<typename T >
constexpr const T & plask::Vec< 3, T >::z_up_y ( ) const
inlineconstexpr

Definition at line 78 of file 3d.hpp.

◆ z_up_z()

template<typename T >
constexpr const T & plask::Vec< 3, T >::z_up_z ( ) const
inlineconstexpr

Definition at line 81 of file 3d.hpp.

◆ zup_x()

template<typename T >
T & plask::Vec< 3, T >::zup_x ( )
inline

Definition at line 74 of file 3d.hpp.

◆ zup_y()

template<typename T >
T & plask::Vec< 3, T >::zup_y ( )
inline

Definition at line 77 of file 3d.hpp.

◆ zup_z()

template<typename T >
T & plask::Vec< 3, T >::zup_z ( )
inline

Definition at line 80 of file 3d.hpp.

Friends And Related Symbol Documentation

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
const Vec< 3, T > &  to_print 
)
friend

Print vector to stream using format (where c0, c1 and c2 are vector coordinates): [c0, c1, c2].

Parameters
outprint destination, output stream
to_printvector to print
Returns
out stream

Definition at line 398 of file 3d.hpp.

Member Data Documentation

◆ c0

template<typename T >
T plask::Vec< 3, T >::c0

Vector components.

Definition at line 42 of file 3d.hpp.

◆ c1

template<typename T >
T plask::Vec< 3, T >::c1

Definition at line 42 of file 3d.hpp.

◆ c2

template<typename T >
T plask::Vec< 3, T >::c2

Definition at line 42 of file 3d.hpp.

◆ DIMS

template<typename T >
const int plask::Vec< 3, T >::DIMS = 3
static

Definition at line 39 of file 3d.hpp.


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