cgv
Loading...
Searching...
No Matches
cgv::math::qem< T > Class Template Reference

dimension independent implementation of quadric error metrics More...

#include <qem.h>

Inheritance diagram for cgv::math::qem< T >:
cgv::math::vec< T >

Public Member Functions

 qem (int d=-1)
 standard constructor initializes qem based on dimension
 
 qem (const vec< T > &p, const vec< T > &n)
 construct from point and normal
 
 qem (const vec< T > &n, T d)
 construct from normal and distance to origin
 
void set (const vec< T > &n, T d)
 set from normal and distance to origin
 
unsigned dim () const
 number of elements
 
qem< T > & operator= (const qem< T > &v)
 assignment of a vector v
 
const T & scalar_part () const
 return the scalar part of the qem
 
vec< T > vector_part () const
 return the vector part of the qem
 
mat< T > matrix_part () const
 return matrix part
 
evaluate (const vec< T > &p) const
 evaluate the quadric error metric at given location
 
vec< T > minarg (const vec< T > &p_ref, T relative_epsilon, T max_distance=-1, T epsilon=1e-10) const
 compute point that minimizes distance to qem and is inside the sphere of radius max_distance around p_ref.
 
template<typename S >
qem< T > & operator+= (const qem< S > &v)
 in place qem addition
 
template<typename S >
qem< T > & operator-= (const qem< S > &v)
 in place qem subtraction
 
template<typename S >
const qem< T > operator+ (const qem< S > &v) const
 qem addition
 
template<typename S >
qem< T > operator- (const qem< S > &v) const
 qem subtraction
 
qem< T > operator- (void) const
 negates the qem
 
qem< T > operator* (const T &s) const
 multiplication with scalar s
 
qem< T > operator/ (const T &s) const
 divides vector by scalar s
 
void resize (unsigned d)
 resize the vector
 
template<typename S >
bool operator== (const qem< S > &v) const
 test for equality
 
template<typename S >
bool operator!= (const qem< S > &v) const
 test for inequality
 
- Public Member Functions inherited from cgv::math::vec< T >
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
unsigned size () const
 number of elements
 
unsigned dim () const
 number of elements
 
 vec ()
 standard constructor
 
 vec (unsigned dim, const T &value=T(0))
 creates a vector with dim elements
 
 vec (unsigned dim, const T *marray)
 creates a vector with dim elements from an array
 
 vec (const vec< T > &v)
 copy constructor for vectors with equal element type

 
template<typename S >
 vec (const vec< S > &v)
 copy constructor for vectors with different element type
 
 vec (const T &c0, const T &c1)
 creates a 2d vector (c0,c1)^T
 
 vec (const T &c0, const T &c1, const T &c2)
 creates a 3d vector (c0,c1,c2)^T
 
 vec (const T &c0, const T &c1, const T &c2, const T &c3)
 creates a 4d vector (c0,c1,c2,c3)^T
 
void set (const T &c0, const T &c1)
 set entries of a 2d vector
 
void set (const T &c0, const T &c1, const T &c2)
 set entries of a 3d vector
 
void set (const T &c0, const T &c1, const T &c2, const T &c3)
 set entries of a 4d vector
 
void set_extern_data (unsigned dim, T *data)
 set data pointer to an external data array
 
virtual ~vec ()
 destructor
 
void destruct ()
 
T * data ()
 cast into non const array
 
const T * data () const
 cast into const array
 
vec< T > & operator= (const vec< T > &v)
 assignment of a vector v
 
vec< T > & operator= (const T &s)
 assignment of a scalar s
 
template<typename S >
vec< T > & operator= (const vec< S > &v)
 assignment of a vector v
 
T & operator() (unsigned i)
 element accessor
 
const T & operator() (unsigned i) const
 const element accessor
 
T & operator[] (unsigned i)
 element accessor
 
const T & operator[] (unsigned i) const
 const element accessor
 
T & first ()
 element accessor for the first element
 
const T & first () const
 const element accessor for the first element
 
T & last ()
 element accessor for the flast element
 
const T & last () const
 const element accessor for the last element
 
T & x ()
 element accessor for the first element
 
const T & x () const
 const element accessor for the first element
 
T & y ()
 element accessor for the second element
 
const T & y () const
 const element accessor for the second element
 
T & z ()
 element accessor for the third element
 
const T & z () const
 const element accessor for the third element
 
T & w ()
 element accessor for the fourth element
 
const T & w () const
 const element accessor for the fourth element
 
vec< T > & operator+= (const T &s)
 in place addition of a scalar s
 
vec< T > & operator-= (const T &s)
 in place subtraction by scalar s
 
vec< T > & operator*= (const T &s)
 in place multiplication with s
 
vec< T > & operator/= (const T &s)
 in place division by scalar s
 
template<typename S >
vec< T > & operator+= (const vec< S > &v)
 in place vector addition
 
template<typename S >
vec< T > & operator-= (const vec< S > &v)
 in place vector subtraction
 
template<typename S >
vec< T > & operator*= (const vec< S > &v)
 in place componentwise vector multiplication
 
template<typename S >
vec< T > & operator/= (const vec< S > &v)
 in place componentwise vector division
 
template<typename S >
const vec< T > operator+ (const vec< S > &v) const
 vector addition
 
const vec< T > operator+ (const T &s) const
 componentwise addition of scalar
 
const vec< T > operator- (const T &s) const
 componentwise subtraction of scalar
 
template<typename S >
vec< T > operator- (const vec< S > &v) const
 vector subtraction
 
template<typename S >
const vec< T > operator* (const vec< S > &v) const
 componentwise vector multiplication
 
template<typename S >
const vec< T > operator/ (const vec< S > &v) const
 componentwise vector division
 
vec< T > operator- (void) const
 negates the vector
 
vec< T > operator* (const T &s) const
 multiplication with scalar s
 
vec< T > operator/ (const T &s) const
 divides vector by scalar s
 
void fill (const T &v)
 fill elements of vector with scalar v
 
void zeros ()
 fill the vector with zeros
 
void ones ()
 fill the vector with ones
 
void zeros (unsigned n)
 resize the vector to size n and fills the vector with zeros
 
void ones (unsigned n)
 resize the vector to size n and fills thevector with ones
 
void resize (unsigned dim)
 resize the vector
 
template<typename S >
bool operator== (const vec< S > &v) const
 test for equality
 
template<typename S >
bool operator!= (const vec< S > &v) const
 test for inequality
 
length () const
 length of the vector L2-Norm
 
void abs ()
 componentwise absolute values
 
void ceil ()
 ceil componentwise
 
void floor ()
 floor componentwise
 
void round ()
 round componentwise
 
sqr_length () const
 square length of vector
 
void normalize ()
 normalize the vector using the L2-Norm
 
void safe_normalize ()
 normalize the vector if length is not zero using the L2-Norm
 
vec< T > sub_vec (unsigned ifrom, unsigned size) const
 extracts sub vector beginning at index ifrom with given size
 
void copy (unsigned ifrom, unsigned s, vec< T > &subvec) const
 copy sub vector beginning at index ifrom with given size s into subvec
 
void paste (unsigned ifrom, const vec< T > &v)
 paste v into vector beginning at index pos ifrom
 

Static Public Member Functions

static bool inside (const vec< T > &p, const vec< T > &minp, const vec< T > &maxp)
 

Additional Inherited Members

- Public Types inherited from cgv::math::vec< T >
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
 
- Protected Attributes inherited from cgv::math::vec< T >
T * _data
 pointer to _data storage
 
unsigned _size
 number or elements
 
bool data_is_external
 store whether data is not owned by vector
 

Detailed Description

template<typename T>
class cgv::math::qem< T >

dimension independent implementation of quadric error metrics

Definition at line 13 of file qem.h.

Constructor & Destructor Documentation

◆ qem() [1/3]

template<typename T >
cgv::math::qem< T >::qem ( int  d = -1)
inline

standard constructor initializes qem based on dimension

Definition at line 17 of file qem.h.

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

◆ qem() [2/3]

template<typename T >
cgv::math::qem< T >::qem ( const vec< T > &  p,
const vec< T > &  n 
)
inline

construct from point and normal

Definition at line 23 of file qem.h.

References cgv::math::qem< T >::set().

◆ qem() [3/3]

template<typename T >
cgv::math::qem< T >::qem ( const vec< T > &  n,
d 
)
inline

construct from normal and distance to origin

Definition at line 28 of file qem.h.

References cgv::math::qem< T >::set().

Member Function Documentation

◆ dim()

template<typename T >
unsigned cgv::math::qem< T >::dim ( ) const
inline

◆ evaluate()

template<typename T >
T cgv::math::qem< T >::evaluate ( const vec< T > &  p) const
inline

evaluate the quadric error metric at given location

Definition at line 79 of file qem.h.

References cgv::math::qem< T >::matrix_part(), cgv::math::qem< T >::scalar_part(), and cgv::math::qem< T >::vector_part().

◆ inside()

template<typename T >
static bool cgv::math::qem< T >::inside ( const vec< T > &  p,
const vec< T > &  minp,
const vec< T > &  maxp 
)
inlinestatic

Definition at line 83 of file qem.h.

◆ matrix_part()

template<typename T >
mat< T > cgv::math::qem< T >::matrix_part ( ) const
inline

return matrix part

Definition at line 68 of file qem.h.

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

Referenced by cgv::math::qem< T >::evaluate(), and cgv::math::qem< T >::minarg().

◆ minarg()

template<typename T >
vec< T > cgv::math::qem< T >::minarg ( const vec< T > &  p_ref,
relative_epsilon,
max_distance = -1,
epsilon = 1e-10 
) const
inline

compute point that minimizes distance to qem and is inside the sphere of radius max_distance around p_ref.

If max_distance is -1, no sphere inclusion test is performed. relative_epsilon gives the absolute value of the fraction betweenan eigenvalue and the largest eigenvalue before it is set to zero. epsilon is a global limit on the absolute value of a singular value before accepted as non zero.

Definition at line 98 of file qem.h.

References cgv::math::qem< T >::dim(), cgv::math::qem< T >::matrix_part(), cgv::math::vec< T >::size(), cgv::math::vec< T >::sqr_length(), cgv::math::mat< T >::transpose(), cgv::math::qem< T >::vector_part(), and cgv::math::vec< T >::y().

Referenced by cgv::media::mesh::dual_contouring< X, T >::compute_cell_vertex().

◆ operator!=()

template<typename T >
template<typename S >
bool cgv::math::qem< T >::operator!= ( const qem< S > &  v) const
inline

test for inequality

Definition at line 196 of file qem.h.

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

◆ operator*()

template<typename T >
qem< T > cgv::math::qem< T >::operator* ( const T &  s) const
inline

multiplication with scalar s

Definition at line 165 of file qem.h.

◆ operator+()

template<typename T >
template<typename S >
const qem< T > cgv::math::qem< T >::operator+ ( const qem< S > &  v) const
inline

qem addition

Definition at line 144 of file qem.h.

◆ operator+=()

template<typename T >
template<typename S >
qem< T > & cgv::math::qem< T >::operator+= ( const qem< S > &  v)
inline

in place qem addition

Definition at line 128 of file qem.h.

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

◆ operator-() [1/2]

template<typename T >
template<typename S >
qem< T > cgv::math::qem< T >::operator- ( const qem< S > &  v) const
inline

qem subtraction

Definition at line 151 of file qem.h.

◆ operator-() [2/2]

template<typename T >
qem< T > cgv::math::qem< T >::operator- ( void  ) const
inline

negates the qem

Definition at line 157 of file qem.h.

◆ operator-=()

template<typename T >
template<typename S >
qem< T > & cgv::math::qem< T >::operator-= ( const qem< S > &  v)
inline

in place qem subtraction

Definition at line 136 of file qem.h.

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

◆ operator/()

template<typename T >
qem< T > cgv::math::qem< T >::operator/ ( const T &  s) const
inline

divides vector by scalar s

Definition at line 172 of file qem.h.

◆ operator=()

template<typename T >
qem< T > & cgv::math::qem< T >::operator= ( const qem< T > &  v)
inline

assignment of a vector v

Definition at line 49 of file qem.h.

◆ operator==()

template<typename T >
template<typename S >
bool cgv::math::qem< T >::operator== ( const qem< S > &  v) const
inline

test for equality

Definition at line 187 of file qem.h.

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

◆ resize()

template<typename T >
void cgv::math::qem< T >::resize ( unsigned  d)
inline

resize the vector

Definition at line 180 of file qem.h.

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

◆ scalar_part()

template<typename T >
const T & cgv::math::qem< T >::scalar_part ( ) const
inline

return the scalar part of the qem

Definition at line 55 of file qem.h.

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

Referenced by cgv::math::qem< T >::evaluate().

◆ set()

template<typename T >
void cgv::math::qem< T >::set ( const vec< T > &  n,
d 
)
inline

set from normal and distance to origin

Definition at line 33 of file qem.h.

References cgv::math::vec< T >::first(), and cgv::math::vec< T >::size().

Referenced by cgv::math::qem< T >::qem(), and cgv::math::qem< T >::qem().

◆ vector_part()

template<typename T >
vec< T > cgv::math::qem< T >::vector_part ( ) const
inline

return the vector part of the qem

Definition at line 60 of file qem.h.

References cgv::math::qem< T >::dim(), and cgv::math::vec< T >::size().

Referenced by cgv::math::qem< T >::evaluate(), and cgv::math::qem< T >::minarg().


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