HerdSoftware  0.4.0
Classes | Public Member Functions | Friends | List of all members
Herd::Vec3D Class Reference

A class describing a vector in 3D space. More...

#include <common/Vec3D.h>

Inheritance diagram for Herd::Vec3D:
Herd::CooArray< float > Herd::ArrayForwarder< float, 3 > Herd::FitDigitizationTools::MCFT::Vec2 Herd::PhysPoint

Classes

class  UndefinedAngle
 Exception class for invalid operations on a undefined angle. More...
 

Public Member Functions

constexpr Vec3D ()
 Default constructor. More...
 
constexpr Vec3D (float x, float y, float z)
 Constructor. More...
 
constexpr Vec3D (std::array< float, 3 > arr)
 Constructor. More...
 
constexpr Vec3D (RefFrame::Direction direction)
 Constructs a 3D vector from a given direction. More...
 
void Dump () const
 Dumps the vector components. More...
 
float Mag () const
 Compute the vector magnitude. More...
 
Vec3D UnitVector () const
 Return this vector, but normalized to unit length. More...
 
constexpr Vec3D CrossProduct (const Vec3D &rhs) const
 Compute the cross product of two vectors. More...
 
float PolarAngle () const
 Compute the polar angle. More...
 
float AzimuthAngle () const
 Compute the azimuth angle. More...
 
Vec3Doperator+= (Vec3D const &right)
 Add a vector to this one. More...
 
Vec3Doperator+= (Vec3D &&right)
 
Vec3D operator- (Vec3D const &right) const
 Subtract two vectors. More...
 
Vec3Doperator-= (Vec3D const &right)
 Subtract a vector from this one. More...
 
Vec3Doperator-= (Vec3D &&right)
 
template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3Doperator*= (T const &right)
 Multiply a vector by a number. More...
 
template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3Doperator*= (T &&right)
 
template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3Doperator/= (T const &right)
 Divide a vector by a number. More...
 
template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3Doperator/= (T &&right)
 
bool operator== (const Vec3D &right) const
 Comparison operator. More...
 
- Public Member Functions inherited from Herd::CooArray< float >
constexpr CooArray ()=default
 Default constructor. More...
 
constexpr CooArray (const CooArray< float > &c)
 Copy constructor. More...
 
constexpr CooArray (U &&v1, V &&v2, Z &&v3)
 Initializer list constructor. More...
 
constexpr CooArray (const std::array< float, 3 > &values)
 Array constructors. More...
 
constexpr CooArray (std::array< float, 3 > &&values)
 
constexpr CooArray< float > & operator= (const CooArray< float > &lhs)
 Assignment operator. More...
 
constexpr float & operator[] (const RefFrame::Coo &coo)
 Accesses an element without validity check on the element index. More...
 
constexpr const float & operator[] (const RefFrame::Coo &coo) const
 Accesses an element without validity check on the element index. More...
 
constexpr float & at (const RefFrame::Coo &coo)
 Accesses an element with validity check on the element index. More...
 
constexpr const float & at (const RefFrame::Coo &coo) const
 Accesses an element with validity check on the element index. More...
 
- Public Member Functions inherited from Herd::ArrayForwarder< float, 3 >
constexpr ArrayForwarder ()=default
 
constexpr ArrayForwarder (std::array< _Tp, _Nm > arr)
 
void fill (const value_type &__u)
 
void swap (ArrayForwarder &__other) noexcept(noexcept(std::swap(std::declval< _Tp & >(), std::declval< _Tp & >())))
 
_GLIBCXX17_CONSTEXPR iterator begin () noexcept
 
_GLIBCXX17_CONSTEXPR const_iterator begin () const noexcept
 
_GLIBCXX17_CONSTEXPR iterator end () noexcept
 
_GLIBCXX17_CONSTEXPR const_iterator end () const noexcept
 
_GLIBCXX17_CONSTEXPR reverse_iterator rbegin () noexcept
 
_GLIBCXX17_CONSTEXPR const_reverse_iterator rbegin () const noexcept
 
_GLIBCXX17_CONSTEXPR reverse_iterator rend () noexcept
 
_GLIBCXX17_CONSTEXPR const_reverse_iterator rend () const noexcept
 
_GLIBCXX17_CONSTEXPR const_iterator cbegin () const noexcept
 
_GLIBCXX17_CONSTEXPR const_iterator cend () const noexcept
 
_GLIBCXX17_CONSTEXPR const_reverse_iterator crbegin () const noexcept
 
_GLIBCXX17_CONSTEXPR const_reverse_iterator crend () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr size_type max_size () const noexcept
 
constexpr bool empty () const noexcept
 
_GLIBCXX17_CONSTEXPR reference operator[] (size_type __n) noexcept
 
constexpr const_reference operator[] (size_type __n) const noexcept
 
_GLIBCXX17_CONSTEXPR reference at (size_type __n)
 
constexpr const_reference at (size_type __n) const
 
_GLIBCXX17_CONSTEXPR reference front () noexcept
 
constexpr const_reference front () const noexcept
 
_GLIBCXX17_CONSTEXPR reference back () noexcept
 
constexpr const_reference back () const noexcept
 
_GLIBCXX17_CONSTEXPR pointer data () noexcept
 
_GLIBCXX17_CONSTEXPR const_pointer data () const noexcept
 

Friends

std::ostream & operator<< (std::ostream &os, const Vec3D &vec)
 Write coordinates to stream. More...
 

Additional Inherited Members

- Public Types inherited from Herd::CooArray< float >
using BaseType = ArrayForwarder< float, 3 >
 
- Public Types inherited from Herd::ArrayForwarder< float, 3 >
typedef _Tp value_type
 
typedef value_typepointer
 
typedef value_typereference
 
typedef value_typeiterator
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
- Public Attributes inherited from Herd::ArrayForwarder< float, 3 >
const typedef value_typeconst_pointer
 
const typedef value_typeconst_reference
 
const typedef value_typeconst_iterator
 

Detailed Description

A class describing a vector in 3D space.

The Vec3D class provides vector functionality in 3D space. It also provides some utility operations common on vectors: such as multiplication by a scalar and addition.

Constructor & Destructor Documentation

◆ Vec3D() [1/4]

constexpr Herd::Vec3D::Vec3D ( )
inlineconstexpr

Default constructor.

Creates a vector with undefined coordinates.

◆ Vec3D() [2/4]

constexpr Herd::Vec3D::Vec3D ( float  x,
float  y,
float  z 
)
inlineconstexpr

Constructor.

Creates a vector from three coordinates.

◆ Vec3D() [3/4]

constexpr Herd::Vec3D::Vec3D ( std::array< float, 3 >  arr)
inlineconstexpr

Constructor.

Creates a vector from a std::array.

◆ Vec3D() [4/4]

constexpr Herd::Vec3D::Vec3D ( RefFrame::Direction  direction)
inlineconstexpr

Constructs a 3D vector from a given direction.

Parameters
directionThe given direction.

Member Function Documentation

◆ AzimuthAngle()

float Herd::Vec3D::AzimuthAngle ( ) const
inline

Compute the azimuth angle.

Returns
The vector azimuth angle.

◆ CrossProduct()

constexpr Vec3D Herd::Vec3D::CrossProduct ( const Vec3D rhs) const
inlineconstexpr

Compute the cross product of two vectors.

Computes the cross product between this vector (lhs) and the argument vector (rhs): lhs x rhs.

Parameters
rhsThe vector to compute the cross product with.
Returns
the cross product between this vector and rhs.

◆ Dump()

void Herd::Vec3D::Dump ( ) const
inline

Dumps the vector components.

◆ Mag()

float Herd::Vec3D::Mag ( ) const
inline

Compute the vector magnitude.

Returns
The vector magnitude.

◆ operator*=() [1/2]

template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3D& Herd::Vec3D::operator*= ( T &&  right)
inline

◆ operator*=() [2/2]

template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3D& Herd::Vec3D::operator*= ( T const &  right)
inline

Multiply a vector by a number.

Returns
The resulting vector.

◆ operator+=() [1/2]

Vec3D& Herd::Vec3D::operator+= ( Vec3D &&  right)
inline

◆ operator+=() [2/2]

Vec3D& Herd::Vec3D::operator+= ( Vec3D const &  right)
inline

Add a vector to this one.

Returns
The resulting vector.

◆ operator-()

Vec3D Herd::Vec3D::operator- ( Vec3D const &  right) const
inline

Subtract two vectors.

Returns
The resulting vector.

◆ operator-=() [1/2]

Vec3D& Herd::Vec3D::operator-= ( Vec3D &&  right)
inline

◆ operator-=() [2/2]

Vec3D& Herd::Vec3D::operator-= ( Vec3D const &  right)
inline

Subtract a vector from this one.

Returns
The resulting vector.

◆ operator/=() [1/2]

template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3D& Herd::Vec3D::operator/= ( T &&  right)
inline

◆ operator/=() [2/2]

template<typename T , typename std::enable_if< std::is_arithmetic< T >::value >::type * = nullptr>
Vec3D& Herd::Vec3D::operator/= ( T const &  right)
inline

Divide a vector by a number.

Returns
The resulting vector.

◆ operator==()

bool Herd::Vec3D::operator== ( const Vec3D right) const
inline

Comparison operator.

Parameters
rightThe vector to compare with.
Returns
true if the coordinates of the two vectors are equal.

◆ PolarAngle()

float Herd::Vec3D::PolarAngle ( ) const
inline

Compute the polar angle.

Returns
The vector polar angle.

◆ UnitVector()

Vec3D Herd::Vec3D::UnitVector ( ) const
inline

Return this vector, but normalized to unit length.

Returns
this vector, but normalized to unit length

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Vec3D vec 
)
friend

Write coordinates to stream.


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