cgv
Loading...
Searching...
No Matches
cgv::math::fvec< T, N > Class Template Reference

A vector with zero based index. More...

#include <fvec.h>

Inheritance diagram for cgv::math::fvec< T, N >:
cgv::math::fmat< volume::coord_type, 3, 3 > cgv::math::fmat< float, 4, 4 > cgv::math::fmat< float, 3, 3 > cgv::math::fmat< float, 3, 4 > cgv::math::quaternion< float >

Public Types

enum  { dims = N }
 compile-time constant indicating the dimensionality of the vector More...
 
typedef T value_type
 
typedef T & reference
 
typedef const T & const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T * iterator
 
typedef const T * const_iterator
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 

Public Member Functions

 fvec ()
 create an uninitialized vector
 
 fvec (const T &a)
 create a vector where all N components are initialized to the constant value a
 
int int S2 fvec (const fvec< S1, N - 1 > &other, S2 s)
 
template<typename S >
 fvec (const fvec< S, N+1 > &other)
 construct from vector of one dimension higher by dropping the highest dimension
 
 fvec (const std::array< T, N > &arr)
 construct from std::array of same size
 
void assign (const std::array< T, N > &arr)
 set to the contents of the given std::array with same size
 
int int N lift () const
 
vec< T > to_vec () const
 conversion to vector type
 
T & x ()
 return first component
 
const T & x () const
 return first component
 
T & y ()
 return second component
 
const T & y () const
 return second component
 
T & z ()
 return third component
 
const T & z () const
 return third component
 
T & w ()
 return fourth component
 
const T & w () const
 return fourth component
 
T & operator[] (int i)
 return a reference to the component at specified index i
 
const T & operator[] (int i) const
 return a reference to the component at specified index i
 
T & operator() (int i)
 return a reference to the component at specified index i
 
const T & operator() (int i) const
 return a reference to the component at specified index i
 
T * data ()
 return a pointer to the underlying array serving as component storage
 
const T * data () const
 return a pointer to the underlying array serving as component storage
 
iterator begin ()
 return an iterator to the first component of *this
 
iterator end ()
 return an iterator past the last component of *this
 
const_iterator begin () const
 return an iterator to the first component of *this
 
const_iterator end () const
 return an iterator past the last component of *this
 
reverse_iterator rbegin ()
 return a reverse iterator to the first component of the reversed *this that corresponds to the last component of the non-reversed *this
 
reverse_iterator rend ()
 return a reverse iterator past the last component of the reversed *this that corresponds to the component preceding the first component of the non-reversed *this
 
const_reverse_iterator rbegin () const
 return a reverse iterator to the first component of the reversed *this that corresponds to the last component of the non-reversed *this
 
const_reverse_iterator rend () const
 return a reverse iterator past the last component of the reversed *this that corresponds to the component preceding the first component of the non-reversed *this
 
fvec< T, N > & operator+= (const T &s)
 in place addition of a scalar s
 
fvec< T, N > & operator-= (const T &s)
 in place subtraction by scalar s
 
fvec< T, N > & operator*= (const T &s)
 in place multiplication with s
 
fvec< T, N > & operator/= (const T &s)
 in place division by scalar s
 
template<typename S >
fvec< T, N > & operator+= (const fvec< S, N > &v)
 in place vector addition
 
template<typename S >
fvec< T, N > & operator-= (const fvec< S, N > &v)
 in place vector subtraction
 
template<typename S >
fvec< T, N > & operator*= (const fvec< S, N > &v)
 in place componentwise vector multiplication
 
template<typename S >
fvec< T, N > & operator/= (const fvec< S, N > &v)
 in place componentwise vector division
 
template<typename S >
fvec< T, N > operator+ (const fvec< S, N > &v) const
 vector addition
 
template<typename S >
fvec< T, N > operator- (const fvec< S, N > &v) const
 vector subtraction
 
template<typename S >
fvec< T, N > operator* (const fvec< S, N > &v) const
 componentwise vector multiplication
 
template<typename S >
fvec< T, N > operator/ (const fvec< S, N > &v) const
 componentwise vector division
 
fvec< T, N > operator+ (const T &s) const
 componentwise addition of scalar
 
fvec< T, N > operator- (const T &s) const
 componentwise subtraction of scalar
 
fvec< T, N > operator* (const T &s) const
 multiplication with scalar s
 
fvec< T, N > operator/ (const T &s) const
 divide vector by scalar s
 
fvec< T, N > operator- () const
 negate the vector
 
template<typename S >
bool operator== (const fvec< S, N > &v) const
 test for equality
 
template<typename S >
bool operator!= (const fvec< S, N > &v) const
 test for inequality
 
sqr_length () const
 square length of vector
 
length () const
 length of the vector L2-Norm
 
void sign ()
 componentwise sign values
 
void step (const fvec< T, N > &r)
 componentwise sign values
 
void abs ()
 componentwise absolute values
 
void ceil ()
 ceil componentwise
 
void floor ()
 floor componentwise
 
void round ()
 round componentwise
 
normalize ()
 normalize the vector using the L2-Norm and return the length
 
safe_normalize ()
 normalize the vector using the L2-Norm and return the length; if length is zero the vector remains unchanged
 

Static Public Member Functions

static fvec< T, N > zeroh ()
 constuct a homogeneous zero-vector (yields same result as calling fvec<T, N-1>(0).lift() but is faster)
 
static fvec< T, N > from_vec (const vec< T > &)
 conversion from vector
 
static cgv::type::uint32_type size ()
 return number of components
 

Protected Attributes

v [N]
 

Detailed Description

template<typename T, cgv::type::uint32_type N>
class cgv::math::fvec< T, N >

A vector with zero based index.

Definition at line 26 of file fvec.h.

Member Typedef Documentation

◆ const_iterator

template<typename T , cgv::type::uint32_type N>
typedef const T* cgv::math::fvec< T, N >::const_iterator

Definition at line 51 of file fvec.h.

◆ const_pointer

template<typename T , cgv::type::uint32_type N>
typedef const T* cgv::math::fvec< T, N >::const_pointer

Definition at line 47 of file fvec.h.

◆ const_reference

template<typename T , cgv::type::uint32_type N>
typedef const T& cgv::math::fvec< T, N >::const_reference

Definition at line 39 of file fvec.h.

◆ const_reverse_iterator

template<typename T , cgv::type::uint32_type N>
typedef std::reverse_iterator<const_iterator> cgv::math::fvec< T, N >::const_reverse_iterator

Definition at line 55 of file fvec.h.

◆ difference_type

template<typename T , cgv::type::uint32_type N>
typedef std::ptrdiff_t cgv::math::fvec< T, N >::difference_type

Definition at line 43 of file fvec.h.

◆ iterator

template<typename T , cgv::type::uint32_type N>
typedef T* cgv::math::fvec< T, N >::iterator

Definition at line 49 of file fvec.h.

◆ pointer

template<typename T , cgv::type::uint32_type N>
typedef T* cgv::math::fvec< T, N >::pointer

Definition at line 45 of file fvec.h.

◆ reference

template<typename T , cgv::type::uint32_type N>
typedef T& cgv::math::fvec< T, N >::reference

Definition at line 37 of file fvec.h.

◆ reverse_iterator

template<typename T , cgv::type::uint32_type N>
typedef std::reverse_iterator<iterator> cgv::math::fvec< T, N >::reverse_iterator

Definition at line 53 of file fvec.h.

◆ size_type

template<typename T , cgv::type::uint32_type N>
typedef std::size_t cgv::math::fvec< T, N >::size_type

Definition at line 41 of file fvec.h.

◆ value_type

template<typename T , cgv::type::uint32_type N>
typedef T cgv::math::fvec< T, N >::value_type

Definition at line 35 of file fvec.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T , cgv::type::uint32_type N>
anonymous enum

compile-time constant indicating the dimensionality of the vector

Definition at line 57 of file fvec.h.

Constructor & Destructor Documentation

◆ fvec() [1/5]

template<typename T , cgv::type::uint32_type N>
cgv::math::fvec< T, N >::fvec ( )
inline

create an uninitialized vector

Definition at line 63 of file fvec.h.

◆ fvec() [2/5]

template<typename T , cgv::type::uint32_type N>
cgv::math::fvec< T, N >::fvec ( const T &  a)
inline

create a vector where all N components are initialized to the constant value a

Definition at line 65 of file fvec.h.

◆ fvec() [3/5]

template<typename T , cgv::type::uint32_type N>
int int S2 cgv::math::fvec< T, N >::fvec ( const fvec< S1, N - 1 > &  other,
S2  s 
)
inline

Definition at line 93 of file fvec.h.

◆ fvec() [4/5]

template<typename T , cgv::type::uint32_type N>
template<typename S >
cgv::math::fvec< T, N >::fvec ( const fvec< S, N+1 > &  other)
inline

construct from vector of one dimension higher by dropping the highest dimension

Definition at line 96 of file fvec.h.

◆ fvec() [5/5]

template<typename T , cgv::type::uint32_type N>
cgv::math::fvec< T, N >::fvec ( const std::array< T, N > &  arr)
inline

construct from std::array of same size

Definition at line 98 of file fvec.h.

Member Function Documentation

◆ abs()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::abs ( )
inline

componentwise absolute values

Definition at line 268 of file fvec.h.

◆ assign()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::assign ( const std::array< T, N > &  arr)
inline

set to the contents of the given std::array with same size

Definition at line 100 of file fvec.h.

◆ begin() [1/2]

template<typename T , cgv::type::uint32_type N>
iterator cgv::math::fvec< T, N >::begin ( )
inline

return an iterator to the first component of *this

Definition at line 165 of file fvec.h.

Referenced by cgv::math::fvec< T, N >::rend(), cgv::math::fvec< T, N >::rend(), and cgv::render::clod_point_renderer::set_points().

◆ begin() [2/2]

template<typename T , cgv::type::uint32_type N>
const_iterator cgv::math::fvec< T, N >::begin ( ) const
inline

return an iterator to the first component of *this

Definition at line 169 of file fvec.h.

◆ ceil()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::ceil ( )
inline

ceil componentwise

Definition at line 275 of file fvec.h.

◆ data() [1/2]

◆ data() [2/2]

template<typename T , cgv::type::uint32_type N>
const T * cgv::math::fvec< T, N >::data ( ) const
inline

return a pointer to the underlying array serving as component storage

Definition at line 159 of file fvec.h.

◆ end() [1/2]

template<typename T , cgv::type::uint32_type N>
iterator cgv::math::fvec< T, N >::end ( )
inline

return an iterator past the last component of *this

Definition at line 167 of file fvec.h.

Referenced by cgv::math::fvec< T, N >::rbegin(), and cgv::math::fvec< T, N >::rbegin().

◆ end() [2/2]

template<typename T , cgv::type::uint32_type N>
const_iterator cgv::math::fvec< T, N >::end ( ) const
inline

return an iterator past the last component of *this

Definition at line 171 of file fvec.h.

◆ floor()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::floor ( )
inline

floor componentwise

Definition at line 280 of file fvec.h.

◆ from_vec()

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::from_vec ( const vec< T > &  v)
static

conversion from vector

Definition at line 703 of file fvec.h.

References cgv::math::vec< T >::dim().

◆ length()

◆ lift()

template<typename T , cgv::type::uint32_type N>
int int N cgv::math::fvec< T, N >::lift ( ) const
inline

Definition at line 119 of file fvec.h.

◆ normalize()

◆ operator!=()

template<typename T , cgv::type::uint32_type N>
template<typename S >
bool cgv::math::fvec< T, N >::operator!= ( const fvec< S, N > &  v) const
inline

test for inequality

Definition at line 237 of file fvec.h.

◆ operator()() [1/2]

template<typename T , cgv::type::uint32_type N>
T & cgv::math::fvec< T, N >::operator() ( int  i)
inline

return a reference to the component at specified index i

Definition at line 153 of file fvec.h.

◆ operator()() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::operator() ( int  i) const
inline

return a reference to the component at specified index i

Definition at line 155 of file fvec.h.

◆ operator*() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > cgv::math::fvec< T, N >::operator* ( const fvec< S, N > &  v) const
inline

componentwise vector multiplication

Definition at line 212 of file fvec.h.

◆ operator*() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::operator* ( const T &  s) const
inline

multiplication with scalar s

Definition at line 221 of file fvec.h.

◆ operator*=() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > & cgv::math::fvec< T, N >::operator*= ( const fvec< S, N > &  v)
inline

in place componentwise vector multiplication

Definition at line 200 of file fvec.h.

◆ operator*=() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > & cgv::math::fvec< T, N >::operator*= ( const T &  s)
inline

in place multiplication with s

Definition at line 189 of file fvec.h.

◆ operator+() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > cgv::math::fvec< T, N >::operator+ ( const fvec< S, N > &  v) const
inline

vector addition

Definition at line 206 of file fvec.h.

◆ operator+() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::operator+ ( const T &  s) const
inline

componentwise addition of scalar

Definition at line 217 of file fvec.h.

◆ operator+=() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > & cgv::math::fvec< T, N >::operator+= ( const fvec< S, N > &  v)
inline

in place vector addition

Definition at line 194 of file fvec.h.

◆ operator+=() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > & cgv::math::fvec< T, N >::operator+= ( const T &  s)
inline

in place addition of a scalar s

Definition at line 185 of file fvec.h.

◆ operator-() [1/3]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::operator- ( ) const
inline

negate the vector

Definition at line 226 of file fvec.h.

◆ operator-() [2/3]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > cgv::math::fvec< T, N >::operator- ( const fvec< S, N > &  v) const
inline

vector subtraction

Definition at line 209 of file fvec.h.

◆ operator-() [3/3]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::operator- ( const T &  s) const
inline

componentwise subtraction of scalar

Definition at line 219 of file fvec.h.

◆ operator-=() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > & cgv::math::fvec< T, N >::operator-= ( const fvec< S, N > &  v)
inline

in place vector subtraction

Definition at line 197 of file fvec.h.

◆ operator-=() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > & cgv::math::fvec< T, N >::operator-= ( const T &  s)
inline

in place subtraction by scalar s

Definition at line 187 of file fvec.h.

◆ operator/() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > cgv::math::fvec< T, N >::operator/ ( const fvec< S, N > &  v) const
inline

componentwise vector division

Definition at line 215 of file fvec.h.

◆ operator/() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > cgv::math::fvec< T, N >::operator/ ( const T &  s) const
inline

divide vector by scalar s

Definition at line 223 of file fvec.h.

◆ operator/=() [1/2]

template<typename T , cgv::type::uint32_type N>
template<typename S >
fvec< T, N > & cgv::math::fvec< T, N >::operator/= ( const fvec< S, N > &  v)
inline

in place componentwise vector division

Definition at line 203 of file fvec.h.

◆ operator/=() [2/2]

template<typename T , cgv::type::uint32_type N>
fvec< T, N > & cgv::math::fvec< T, N >::operator/= ( const T &  s)
inline

in place division by scalar s

Definition at line 191 of file fvec.h.

◆ operator==()

template<typename T , cgv::type::uint32_type N>
template<typename S >
bool cgv::math::fvec< T, N >::operator== ( const fvec< S, N > &  v) const
inline

test for equality

Definition at line 230 of file fvec.h.

◆ operator[]() [1/2]

template<typename T , cgv::type::uint32_type N>
T & cgv::math::fvec< T, N >::operator[] ( int  i)
inline

return a reference to the component at specified index i

Definition at line 149 of file fvec.h.

◆ operator[]() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::operator[] ( int  i) const
inline

return a reference to the component at specified index i

Definition at line 151 of file fvec.h.

◆ rbegin() [1/2]

template<typename T , cgv::type::uint32_type N>
reverse_iterator cgv::math::fvec< T, N >::rbegin ( )
inline

return a reverse iterator to the first component of the reversed *this that corresponds to the last component of the non-reversed *this

Definition at line 173 of file fvec.h.

References cgv::math::fvec< T, N >::end().

◆ rbegin() [2/2]

template<typename T , cgv::type::uint32_type N>
const_reverse_iterator cgv::math::fvec< T, N >::rbegin ( ) const
inline

return a reverse iterator to the first component of the reversed *this that corresponds to the last component of the non-reversed *this

Definition at line 177 of file fvec.h.

References cgv::math::fvec< T, N >::end().

◆ rend() [1/2]

template<typename T , cgv::type::uint32_type N>
reverse_iterator cgv::math::fvec< T, N >::rend ( )
inline

return a reverse iterator past the last component of the reversed *this that corresponds to the component preceding the first component of the non-reversed *this

Definition at line 175 of file fvec.h.

References cgv::math::fvec< T, N >::begin().

◆ rend() [2/2]

template<typename T , cgv::type::uint32_type N>
const_reverse_iterator cgv::math::fvec< T, N >::rend ( ) const
inline

return a reverse iterator past the last component of the reversed *this that corresponds to the component preceding the first component of the non-reversed *this

Definition at line 179 of file fvec.h.

References cgv::math::fvec< T, N >::begin().

◆ round()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::round ( )
inline

round componentwise

Definition at line 285 of file fvec.h.

◆ safe_normalize()

template<typename T , cgv::type::uint32_type N>
T cgv::math::fvec< T, N >::safe_normalize ( )
inline

normalize the vector using the L2-Norm and return the length; if length is zero the vector remains unchanged

Definition at line 298 of file fvec.h.

References cgv::math::fvec< T, N >::length().

◆ sign()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::sign ( )
inline

componentwise sign values

Definition at line 258 of file fvec.h.

◆ size()

◆ sqr_length()

template<typename T , cgv::type::uint32_type N>
T cgv::math::fvec< T, N >::sqr_length ( ) const
inline

square length of vector

Definition at line 247 of file fvec.h.

Referenced by cgv::math::distorted_pinhole< T >::invert_distortion_model(), and cgv::math::fvec< T, N >::length().

◆ step()

template<typename T , cgv::type::uint32_type N>
void cgv::math::fvec< T, N >::step ( const fvec< T, N > &  r)
inline

componentwise sign values

Definition at line 263 of file fvec.h.

◆ to_vec()

◆ w() [1/2]

◆ w() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::w ( ) const
inline

return fourth component

Definition at line 147 of file fvec.h.

◆ x() [1/2]

◆ x() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::x ( ) const
inline

return first component

Definition at line 135 of file fvec.h.

◆ y() [1/2]

◆ y() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::y ( ) const
inline

return second component

Definition at line 139 of file fvec.h.

◆ z() [1/2]

◆ z() [2/2]

template<typename T , cgv::type::uint32_type N>
const T & cgv::math::fvec< T, N >::z ( ) const
inline

return third component

Definition at line 143 of file fvec.h.

◆ zeroh()

template<typename T , cgv::type::uint32_type N>
static fvec< T, N > cgv::math::fvec< T, N >::zeroh ( )
inlinestatic

constuct a homogeneous zero-vector (yields same result as calling fvec<T, N-1>(0).lift() but is faster)

Definition at line 121 of file fvec.h.

Member Data Documentation

◆ v

template<typename T , cgv::type::uint32_type N>
T cgv::math::fvec< T, N >::v[N]
protected

Definition at line 29 of file fvec.h.


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