Developer Documentation
OpenMesh::VectorT< Scalar, DIM > Class Template Referenceabstract

#include <OpenMesh/Core/Math/VectorT.hh>

Inheritance diagram for OpenMesh::VectorT< Scalar, DIM >:
ACG::QuaternionT< Scalar > ACG::QuaternionT< double >

Public Types

typedef Scalar value_type
 the type of the scalar used in this template
 
typedef VectorT< Scalar, DIM > vector_type
 type of this vector
 

Public Member Functions

template<typename T , typename ... Ts, typename = typename std::enable_if<sizeof...(Ts)+1 == DIM>::type, typename = typename std::enable_if< are_convertible_to<Scalar, T, Ts...>::value>::type>
constexpr VectorT (T v, Ts... vs)
 
constexpr VectorT ()
 default constructor creates uninitialized values.
 
 VectorT (const Scalar &v)
 
 VectorT (const VectorT &rhs)=default
 
 VectorT (VectorT &&rhs)=default
 
VectorToperator= (const VectorT &rhs)=default
 
VectorToperator= (VectorT &&rhs)=default
 
template<typename S = Scalar, int D = DIM>
auto homogenized () const -> typename std::enable_if< D==4, VectorT< decltype(std::declval< S >()/std::declval< S >()), DIM >>::type
 
template<typename Iterator , typename = decltype( *std::declval<Iterator&>(), void(), ++std::declval<Iterator&>(), void())>
 VectorT (Iterator it)
 construct from a value array or any other iterator
 
template<typename otherScalarType , typename = typename std::enable_if< std::is_convertible<otherScalarType, Scalar>::value>>
 VectorT (const VectorT< otherScalarType, DIM > &_rhs)
 copy & cast constructor (explicit)
 
template<typename OtherScalar , typename = typename std::enable_if< std::is_convertible<OtherScalar, Scalar>::value>>
vector_typeoperator= (const VectorT< OtherScalar, DIM > &_rhs)
 cast from vector with a different scalar type
 
Scalar * data ()
 access to Scalar array
 
const Scalar * data () const
 access to const Scalar array
 
Scalar & operator[] (size_t _i)
 get i'th element read-write
 
const Scalar & operator[] (size_t _i) const
 get i'th element read-only
 
bool operator== (const vector_type &_rhs) const
 component-wise comparison
 
bool operator!= (const vector_type &_rhs) const
 component-wise comparison
 
template<typename OtherScalar >
auto operator*= (const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0] *_s), Scalar >::value, VectorT< Scalar, DIM > &>::type
 component-wise self-multiplication with scalar
 
template<typename OtherScalar >
auto operator/= (const OtherScalar &_s) -> typename std::enable_if< std::is_convertible< decltype(this->values_[0]/_s), Scalar >::value, VectorT< Scalar, DIM > &>::type
 component-wise self-division by scalar
 
template<typename OtherScalar >
std::enable_if< std::is_convertible< decltype(std::declval< Scalar >) *std::declval< OtherScalar >)), Scalar >::value, VectorT< Scalar, DIM > >::type operator* (const OtherScalar &_s) const
 component-wise multiplication with scalar
 
template<typename OtherScalar >
std::enable_if< std::is_convertible< decltype(std::declval< Scalar >)/std::declval< OtherScalar >)), Scalar >::value, VectorT< Scalar, DIM > >::type operator/ (const OtherScalar &_s) const
 component-wise division by with scalar
 
template<typename OtherScalar >
auto operator*= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0] **_rhs.data())) >=0
 component-wise self-multiplication
 
template<typename OtherScalar >
auto operator/= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0]/*_rhs.data())) >=0
 component-wise self-division
 
template<typename OtherScalar >
auto operator-= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0] - *_rhs.data())) >=0
 vector difference from this
 
template<typename OtherScalar >
auto operator+= (const VectorT< OtherScalar, DIM > &_rhs) -> typename std::enable_if< sizeof(decltype(this->values_[0]+ *_rhs.data())) >=0
 vector self-addition
 
template<typename OtherScalar >
auto operator* (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0] **_rhs.data())) >=0
 component-wise vector multiplication
 
template<typename OtherScalar >
auto operator/ (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0]/*_rhs.data())) >=0
 component-wise vector division
 
template<typename OtherScalar >
auto operator+ (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0]+ *_rhs.data())) >=0
 component-wise vector addition
 
template<typename OtherScalar >
auto operator- (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< sizeof(decltype(this->values_[0] - *_rhs.data())) >=0
 component-wise vector difference
 
vector_type operator- (void) const
 unary minus
 
template<typename OtherScalar >
auto operator% (const VectorT< OtherScalar, DIM > &_rhs) const -> typename std::enable_if< DIM==3, VectorT< decltype((*this)[0] *_rhs[0] -(*this)[0] *_rhs[0]), DIM >>::type
 
template<typename OtherScalar >
auto operator| (const VectorT< OtherScalar, DIM > &_rhs) const -> decltype(*this->data() **_rhs.data())
 
template<typename Functor >
vector_type apply (const Functor &_func) const
 component-wise apply function object with Scalar operator()(Scalar).
 
vector_typevectorize (const Scalar &_s)
 store the same value in each component (e.g. to clear all entries)
 
bool operator< (const vector_type &_rhs) const
 lexicographical comparison
 
void swap (VectorT &_other) noexcept(noexcept(std::swap(values_, _other.values_)))
 swap with another vector
 
Euclidean norm calculations
template<typename S = Scalar>
decltype(std::declval< S >() *std::declval< S >()) sqrnorm () const
 compute squared euclidean norm
 
template<typename S = Scalar>
auto norm () const -> decltype(std::sqrt(std::declval< VectorT< S, DIM >>().sqrnorm()))
 compute euclidean norm
 
template<typename S = Scalar>
auto length () const -> decltype(std::declval< VectorT< S, DIM >>().norm())
 compute squared euclidean norm
 
template<typename S = Scalar>
auto normalize () -> decltype(*this/=std::declval< VectorT< S, DIM >>().norm())
 
template<typename S = Scalar>
auto normalized () const -> decltype(*this/std::declval< VectorT< S, DIM >>().norm())
 
template<typename S = Scalar>
vector_type &::type normalize_cond ()
 compute squared euclidean norm
 
Non-Euclidean norm calculations
Scalar l1_norm () const
 compute L1 (Manhattan) norm
 
Scalar l8_norm () const
 compute l8_norm
 
Minimum maximum and mean
Scalar max () const
 return the maximal component
 
Scalar max_abs () const
 return the maximal absolute component
 
Scalar min () const
 return the minimal component
 
Scalar min_abs () const
 return the minimal absolute component
 
Scalar mean () const
 return arithmetic mean
 
Scalar mean_abs () const
 return absolute arithmetic mean
 
vector_typeminimize (const vector_type &_rhs)
 minimize values: same as *this = min(*this, _rhs), but faster
 
bool minimized (const vector_type &_rhs)
 minimize values and signalize coordinate minimization
 
vector_typemaximize (const vector_type &_rhs)
 maximize values: same as *this = max(*this, _rhs), but faster
 
bool maximized (const vector_type &_rhs)
 maximize values and signalize coordinate maximization
 
vector_type min (const vector_type &_rhs) const
 component-wise min
 
vector_type max (const vector_type &_rhs) const
 component-wise max
 

Static Public Member Functions

static constexpr int dim ()
 returns dimension of the vector (deprecated)
 
static constexpr size_t size ()
 returns dimension of the vector
 
static vector_type vectorized (const Scalar &_s)
 store the same value in each component
 

Static Public Attributes

static constexpr const size_t size_ = DIM
 

Private Types

using container = std::array< Scalar, DIM >
 

Private Attributes

container values_
 

Related Functions

(Note that these are not member functions.)

template<typename Scalar1 , typename Scalar2 , int N>
VectorT< Scalar1, N > operator* (Scalar2 _s, const VectorT< Scalar1, N > &_v)
 
template<typename Scalar , int N>
Scalar dot (const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
 
template<typename Scalar , int N>
VectorT< Scalar, N > cross (const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
 
template<typename Scalar , int DIM>
Scalar norm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
Scalar sqrnorm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize (VectorT< Scalar, DIM > &_v, OtherScalar const &_val)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize (VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 
template<typename Scalar , int DIM>
Scalar dot (const VectorT< Scalar, DIM > &_v1, const VectorT< Scalar, DIM > &_v2)
 
template<typename LScalar , typename RScalar , int DIM>
auto cross (const VectorT< LScalar, DIM > &_v1, const VectorT< RScalar, DIM > &_v2) -> decltype(_v1 % _v2)
 
template<typename Scalar , int DIM>
void swap (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2) noexcept(noexcept(_v1.swap(_v2)))
 
template<typename Scalar , int DIM>
Scalar norm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
Scalar sqrnorm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize (VectorT< Scalar, DIM > &_v, OtherScalar const &_val)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize (VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 
template<typename Scalar1 , typename Scalar2 , int N>
VectorT< Scalar1, N > operator* (Scalar2 _s, const VectorT< Scalar1, N > &_v)
 
template<typename Scalar , int N>
Scalar dot (const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
 
template<typename Scalar , int N>
VectorT< Scalar, N > cross (const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
 
template<typename Scalar , int DIM>
Scalar norm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
Scalar sqrnorm (const VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize (VectorT< Scalar, DIM > &_v, OtherScalar const &_val)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize (VectorT< Scalar, DIM > &_v)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 
template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize (VectorT< Scalar, DIM > &_v1, VectorT< Scalar, DIM > &_v2)
 

Component iterators

using iterator = typename container::iterator
 
using const_iterator = typename container::const_iterator
 
using reverse_iterator = typename container::reverse_iterator
 
using const_reverse_iterator = typename container::const_reverse_iterator
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 
reverse_iterator rbegin () noexcept
 
const_reverse_iterator rbegin () const noexcept
 
const_reverse_iterator crbegin () const noexcept
 
reverse_iterator rend () noexcept
 
const_reverse_iterator rend () const noexcept
 
const_reverse_iterator crend () const noexcept
 

Detailed Description

template<typename Scalar, int DIM>
class OpenMesh::VectorT< Scalar, DIM >

A vector is an array of <N> values of type <Scalar>. The actual data is stored in an VectorDataT, this class just adds the necessary operators.

Definition at line 83 of file Vector11T.hh.

Constructor & Destructor Documentation

◆ VectorT()

template<typename Scalar, int DIM>
OpenMesh::VectorT< Scalar, DIM >::VectorT ( const Scalar &  v)
inlineexplicit

Creates a vector with all components set to v.

Definition at line 134 of file Vector11T.hh.

Member Function Documentation

◆ homogenized()

template<typename Scalar, int DIM>
template<typename S = Scalar, int D = DIM>
auto OpenMesh::VectorT< Scalar, DIM >::homogenized ( ) const -> typename std::enable_if<D == 4, VectorT<decltype(std::declval<S>()/std::declval<S>()), DIM>>::type
inline

Only for 4-component vectors with division operator on their Scalar: Dehomogenization.

Definition at line 148 of file Vector11T.hh.

◆ normalize()

template<typename Scalar, int DIM>
template<typename S = Scalar>
auto OpenMesh::VectorT< Scalar, DIM >::normalize ( ) -> decltype(*this /= std::declval<VectorT<S, DIM>>().norm())
inline

normalize vector, return normalized vector

Definition at line 429 of file Vector11T.hh.

◆ normalized()

template<typename Scalar, int DIM>
template<typename S = Scalar>
auto OpenMesh::VectorT< Scalar, DIM >::normalized ( ) const -> decltype(*this / std::declval<VectorT<S, DIM>>().norm())
inline

return normalized vector

Definition at line 440 of file Vector11T.hh.

◆ operator%()

template<typename Scalar, int DIM>
template<typename OtherScalar >
auto OpenMesh::VectorT< Scalar, DIM >::operator% ( const VectorT< OtherScalar, DIM > &  _rhs) const -> typename std::enable_if<DIM == 3, VectorT<decltype((*this)[0] * _rhs[0] - (*this)[0] * _rhs[0]), DIM>>::type
inline

cross product: only defined for Vec3* as specialization

See also
OpenMesh::cross

Definition at line 369 of file Vector11T.hh.

◆ operator|()

template<typename Scalar, int DIM>
template<typename OtherScalar >
auto OpenMesh::VectorT< Scalar, DIM >::operator| ( const VectorT< OtherScalar, DIM > &  _rhs) const -> decltype(*this->data() * *_rhs.data())
inline

compute scalar product

See also
OpenMesh::dot

Definition at line 383 of file Vector11T.hh.

Friends And Related Function Documentation

◆ cross() [1/3]

template<typename Scalar , int N>
VectorT< Scalar, N > cross ( const VectorT< Scalar, N > &  _v1,
const VectorT< Scalar, N > &  _v2 
)
related

symmetric version of the cross product

Definition at line 267 of file MeshNode2T_impl.hh.

◆ cross() [2/3]

template<typename Scalar , int N>
VectorT< Scalar, N > cross ( const VectorT< Scalar, N > &  _v1,
const VectorT< Scalar, N > &  _v2 
)
related

symmetric version of the cross product

Definition at line 267 of file VectorT.hh.

◆ cross() [3/3]

template<typename LScalar , typename RScalar , int DIM>
auto cross ( const VectorT< LScalar, DIM > &  _v1,
const VectorT< RScalar, DIM > &  _v2 
) -> decltype(_v1 % _v2)
related

symmetric version of the cross product

Definition at line 708 of file Vector11T.hh.

◆ dot() [1/3]

template<typename Scalar , int N>
Scalar dot ( const VectorT< Scalar, N > &  _v1,
const VectorT< Scalar, N > &  _v2 
)
related

symmetric version of the dot product

Definition at line 258 of file VectorT.hh.

◆ dot() [2/3]

template<typename Scalar , int N>
Scalar dot ( const VectorT< Scalar, N > &  _v1,
const VectorT< Scalar, N > &  _v2 
)
related

symmetric version of the dot product

Definition at line 258 of file MeshNode2T_impl.hh.

◆ dot() [3/3]

template<typename Scalar , int DIM>
Scalar dot ( const VectorT< Scalar, DIM > &  _v1,
const VectorT< Scalar, DIM > &  _v2 
)
related

symmetric version of the dot product

Definition at line 700 of file Vector11T.hh.

◆ maximize() [1/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member maximize

Definition at line 307 of file MeshNode2T_impl.hh.

◆ maximize() [2/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member maximize

Definition at line 307 of file VectorT.hh.

◆ maximize() [3/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & maximize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member maximize

Definition at line 751 of file Vector11T.hh.

◆ minimize() [1/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member minimize

Definition at line 315 of file MeshNode2T_impl.hh.

◆ minimize() [2/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member minimize

Definition at line 315 of file VectorT.hh.

◆ minimize() [3/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & minimize ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member minimize

Definition at line 758 of file Vector11T.hh.

◆ norm() [1/3]

template<typename Scalar , int DIM>
Scalar norm ( const VectorT< Scalar, DIM > &  _v)
related

non-member norm

Definition at line 275 of file MeshNode2T_impl.hh.

◆ norm() [2/3]

template<typename Scalar , int DIM>
Scalar norm ( const VectorT< Scalar, DIM > &  _v)
related

non-member norm

Definition at line 275 of file VectorT.hh.

◆ norm() [3/3]

template<typename Scalar , int DIM>
Scalar norm ( const VectorT< Scalar, DIM > &  _v)
related

non-member norm

Definition at line 724 of file Vector11T.hh.

◆ normalize() [1/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize ( VectorT< Scalar, DIM > &  _v)
related

non-member normalize

Definition at line 299 of file VectorT.hh.

◆ normalize() [2/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize ( VectorT< Scalar, DIM > &  _v)
related

non-member normalize

Definition at line 299 of file MeshNode2T_impl.hh.

◆ normalize() [3/3]

template<typename Scalar , int DIM>
VectorT< Scalar, DIM > & normalize ( VectorT< Scalar, DIM > &  _v)
related

non-member normalize

Definition at line 744 of file Vector11T.hh.

◆ operator*() [1/2]

template<typename Scalar1 , typename Scalar2 , int N>
VectorT< Scalar1, N > operator* ( Scalar2  _s,
const VectorT< Scalar1, N > &  _v 
)
related

scalar * vector

Definition at line 249 of file MeshNode2T_impl.hh.

◆ operator*() [2/2]

template<typename Scalar1 , typename Scalar2 , int N>
VectorT< Scalar1, N > operator* ( Scalar2  _s,
const VectorT< Scalar1, N > &  _v 
)
related

scalar * vector

Definition at line 249 of file VectorT.hh.

◆ sqrnorm() [1/3]

template<typename Scalar , int DIM>
Scalar sqrnorm ( const VectorT< Scalar, DIM > &  _v)
related

non-member sqrnorm

Definition at line 283 of file VectorT.hh.

◆ sqrnorm() [2/3]

template<typename Scalar , int DIM>
Scalar sqrnorm ( const VectorT< Scalar, DIM > &  _v)
related

non-member sqrnorm

Definition at line 283 of file MeshNode2T_impl.hh.

◆ sqrnorm() [3/3]

template<typename Scalar , int DIM>
Scalar sqrnorm ( const VectorT< Scalar, DIM > &  _v)
related

non-member sqrnorm

Definition at line 731 of file Vector11T.hh.

◆ swap()

template<typename Scalar , int DIM>
void swap ( VectorT< Scalar, DIM > &  _v1,
VectorT< Scalar, DIM > &  _v2 
)
related

non-member swap

Definition at line 716 of file Vector11T.hh.

◆ vectorize() [1/3]

template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize ( VectorT< Scalar, DIM > &  _v,
OtherScalar const &  _val 
)
related

non-member vectorize

Definition at line 291 of file MeshNode2T_impl.hh.

◆ vectorize() [2/3]

template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize ( VectorT< Scalar, DIM > &  _v,
OtherScalar const &  _val 
)
related

non-member vectorize

Definition at line 291 of file VectorT.hh.

◆ vectorize() [3/3]

template<typename Scalar , int DIM, typename OtherScalar >
VectorT< Scalar, DIM > & vectorize ( VectorT< Scalar, DIM > &  _v,
OtherScalar const &  _val 
)
related

non-member vectorize

Definition at line 737 of file Vector11T.hh.


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