Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Friends | List of all members
lvr2::BaseVector< CoordT > Struct Template Reference

A generic, weakly-typed vector. More...

#include <BaseVector.hpp>

Public Types

using CoordType = CoordT
 

Public Member Functions

 BaseVector ()
 Default constructs a null-vector. More...
 
 BaseVector (const CoordT &x, const CoordT &y, const CoordT &z)
 Builds a BaseVector with the given coordinates. More...
 
 BaseVector (const BaseVector &o)
 
BaseVector< CoordT > cross (const BaseVector &other) const
 Calculates the cross product between this and the given vector. Returns a new BaseVector instance. More...
 
CoordT distance (const BaseVector &other) const
 Calculates the distance to another vector. More...
 
CoordT distance2 (const BaseVector &other) const
 Calculates the squared distance to another vector. More...
 
CoordType distanceFrom (const BaseVector< CoordT > &other) const
 
CoordT dot (const BaseVector &other) const
 Calculates the dot product between this and the given vector. More...
 
CoordT length () const
 Returns the length of this vector. More...
 
CoordT length2 () const
 Returns the squared length of this vector. More...
 
void normalize ()
 
Normal< CoordT > normalized () const
 Returns a normalized version of this vector. More...
 
bool operator!= (const BaseVector &other) const
 
BaseVector< CoordT > operator* (const CoordT &scale) const
 Scalar multiplication. More...
 
CoordT operator* (const BaseVector< CoordType > &other) const
 
BaseVector< CoordT > & operator*= (const CoordT &scale)
 Scalar multiplication. More...
 
BaseVector< CoordT > operator+ (const BaseVector &other) const
 Element-wise addition. More...
 
BaseVector< CoordT > & operator+= (const BaseVector< CoordT > &other)
 Element-wise addition. More...
 
BaseVector< CoordT > operator- (const BaseVector &other) const
 Element-wise subtraction. More...
 
BaseVector< CoordT > & operator-= (const BaseVector< CoordT > &other)
 Element-wise subtraction. More...
 
BaseVector< CoordT > operator/ (const CoordT &scale) const
 Scalar division. More...
 
BaseVector< CoordT > & operator/= (const CoordT &scale)
 Scalar division. More...
 
bool operator== (const BaseVector &other) const
 
CoordT operator[] (const unsigned &index) const
 Indexed coordinate access (reading) More...
 
CoordT & operator[] (const unsigned &index)
 Indexed coordinate access (writing) More...
 
BaseVector< CoordT > rotated (const BaseVector &n, const double &alpha) const
 Calculates the rotated vector around an normal vector n with the rotation angle alpha. More...
 
CoordType squaredDistanceFrom (const BaseVector< CoordType > &other) const
 

Static Public Member Functions

template<typename CollectionT >
static BaseVector< CoordT > average (const CollectionT &vecs)
 Returns the average of all vectors in the given collection. More...
 
template<typename CollectionT >
static BaseVector< CoordT > centroid (const CollectionT &points)
 Returns the centroid of all points in the given collection. More...
 

Public Attributes

CoordT x
 
CoordT y
 
CoordT z
 

Friends

template<typename T , typename S >
BaseVector< T > operator* (const Eigen::Matrix< S, 4, 4 > &mat, const BaseVector< T > &normal)
 

Detailed Description

template<typename CoordT>
struct lvr2::BaseVector< CoordT >

A generic, weakly-typed vector.

This vector is weakly-typed as it allows all common operations that can be executed numerically. Instead of this, BaseVector implementations from other libraries could be used. However, they have to provide all the methods and fields that BaseVector defines.

Definition at line 60 of file BaseVector.hpp.

Member Typedef Documentation

◆ CoordType

template<typename CoordT>
using lvr2::BaseVector< CoordT >::CoordType = CoordT

Definition at line 63 of file BaseVector.hpp.

Constructor & Destructor Documentation

◆ BaseVector() [1/3]

template<typename CoordT>
lvr2::BaseVector< CoordT >::BaseVector ( )
inline

Default constructs a null-vector.

Definition at line 70 of file BaseVector.hpp.

◆ BaseVector() [2/3]

template<typename CoordT>
lvr2::BaseVector< CoordT >::BaseVector ( const CoordT &  x,
const CoordT &  y,
const CoordT &  z 
)
inline

Builds a BaseVector with the given coordinates.

Definition at line 73 of file BaseVector.hpp.

◆ BaseVector() [3/3]

template<typename CoordT>
lvr2::BaseVector< CoordT >::BaseVector ( const BaseVector< CoordT > &  o)
inline

Definition at line 78 of file BaseVector.hpp.

Member Function Documentation

◆ average()

template<typename CoordT>
template<typename CollectionT >
static BaseVector<CoordT> lvr2::BaseVector< CoordT >::average ( const CollectionT &  vecs)
static

Returns the average of all vectors in the given collection.

The collection need to work with a range-based for-loop and its elements need to be Vector<BaseVecT>. It has to contain at least one element.

◆ centroid()

template<typename CoordT>
template<typename CollectionT >
static BaseVector<CoordT> lvr2::BaseVector< CoordT >::centroid ( const CollectionT &  points)
static

Returns the centroid of all points in the given collection.

The collection need to work with a range-based for-loop and its elements need to be Point<BaseVecT>. It has to contain at least one element.

◆ cross()

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::cross ( const BaseVector< CoordT > &  other) const

Calculates the cross product between this and the given vector. Returns a new BaseVector instance.

◆ distance()

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::distance ( const BaseVector< CoordT > &  other) const

Calculates the distance to another vector.

◆ distance2()

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::distance2 ( const BaseVector< CoordT > &  other) const

Calculates the squared distance to another vector.

The squared distance is easier to calculate and sufficient for certain uses cases. This method only exists for performance reasons.

◆ distanceFrom()

template<typename CoordT>
CoordType lvr2::BaseVector< CoordT >::distanceFrom ( const BaseVector< CoordT > &  other) const

◆ dot()

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::dot ( const BaseVector< CoordT > &  other) const

Calculates the dot product between this and the given vector.

◆ length()

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::length ( ) const

Returns the length of this vector.

◆ length2()

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::length2 ( ) const

Returns the squared length of this vector.

The squared length is easier to calculate and sufficient for certain uses cases. This method only exists for performance reasons.

◆ normalize()

template<typename CoordT>
void lvr2::BaseVector< CoordT >::normalize ( )
inline

Definition at line 130 of file BaseVector.hpp.

◆ normalized()

template<typename CoordT>
Normal<CoordT> lvr2::BaseVector< CoordT >::normalized ( ) const

Returns a normalized version of this vector.

Note that this must not be the null vector, or else the behavior is undefined.

◆ operator!=()

template<typename CoordT>
bool lvr2::BaseVector< CoordT >::operator!= ( const BaseVector< CoordT > &  other) const

◆ operator*() [1/2]

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator* ( const CoordT &  scale) const

Scalar multiplication.

◆ operator*() [2/2]

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::operator* ( const BaseVector< CoordType > &  other) const

◆ operator*=()

template<typename CoordT>
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator*= ( const CoordT &  scale)

Scalar multiplication.

◆ operator+()

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator+ ( const BaseVector< CoordT > &  other) const

Element-wise addition.

◆ operator+=()

template<typename CoordT>
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator+= ( const BaseVector< CoordT > &  other)

Element-wise addition.

◆ operator-()

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator- ( const BaseVector< CoordT > &  other) const

Element-wise subtraction.

◆ operator-=()

template<typename CoordT>
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator-= ( const BaseVector< CoordT > &  other)

Element-wise subtraction.

◆ operator/()

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator/ ( const CoordT &  scale) const

Scalar division.

◆ operator/=()

template<typename CoordT>
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator/= ( const CoordT &  scale)

Scalar division.

◆ operator==()

template<typename CoordT>
bool lvr2::BaseVector< CoordT >::operator== ( const BaseVector< CoordT > &  other) const

◆ operator[]() [1/2]

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::operator[] ( const unsigned &  index) const

Indexed coordinate access (reading)

◆ operator[]() [2/2]

template<typename CoordT>
CoordT& lvr2::BaseVector< CoordT >::operator[] ( const unsigned &  index)

Indexed coordinate access (writing)

◆ rotated()

template<typename CoordT>
BaseVector<CoordT> lvr2::BaseVector< CoordT >::rotated ( const BaseVector< CoordT > &  n,
const double &  alpha 
) const

Calculates the rotated vector around an normal vector n with the rotation angle alpha.

◆ squaredDistanceFrom()

template<typename CoordT>
CoordType lvr2::BaseVector< CoordT >::squaredDistanceFrom ( const BaseVector< CoordType > &  other) const

Friends And Related Function Documentation

◆ operator*

template<typename CoordT>
template<typename T , typename S >
BaseVector<T> operator* ( const Eigen::Matrix< S, 4, 4 > &  mat,
const BaseVector< T > &  normal 
)
friend

Member Data Documentation

◆ x

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::x

Definition at line 65 of file BaseVector.hpp.

◆ y

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::y

Definition at line 66 of file BaseVector.hpp.

◆ z

template<typename CoordT>
CoordT lvr2::BaseVector< CoordT >::z

Definition at line 67 of file BaseVector.hpp.


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


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:11