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 BaseVector &o) | |
BaseVector (const CoordT &x, const CoordT &y, const CoordT &z) | |
Builds a BaseVector with the given coordinates. More... | |
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 |
CoordT | operator* (const BaseVector< CoordType > &other) const |
BaseVector< CoordT > | operator* (const CoordT &scale) const |
Scalar multiplication. More... | |
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) |
Indexed coordinate access (writing) More... | |
CoordT | operator[] (const unsigned &index) const |
Indexed coordinate access (reading) 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) |
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.
using lvr2::BaseVector< CoordT >::CoordType = CoordT |
Definition at line 63 of file BaseVector.hpp.
|
inline |
Default constructs a null-vector.
Definition at line 70 of file BaseVector.hpp.
|
inline |
Builds a BaseVector with the given coordinates.
Definition at line 73 of file BaseVector.hpp.
|
inline |
Definition at line 78 of file BaseVector.hpp.
|
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.
|
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.
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.
CoordT lvr2::BaseVector< CoordT >::distance | ( | const BaseVector< CoordT > & | other | ) | const |
Calculates the distance to another vector.
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.
CoordType lvr2::BaseVector< CoordT >::distanceFrom | ( | const BaseVector< CoordT > & | other | ) | const |
CoordT lvr2::BaseVector< CoordT >::dot | ( | const BaseVector< CoordT > & | other | ) | const |
Calculates the dot product between this and the given vector.
CoordT lvr2::BaseVector< CoordT >::length | ( | ) | const |
Returns the length of this vector.
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.
|
inline |
Definition at line 130 of file BaseVector.hpp.
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.
bool lvr2::BaseVector< CoordT >::operator!= | ( | const BaseVector< CoordT > & | other | ) | const |
CoordT lvr2::BaseVector< CoordT >::operator* | ( | const BaseVector< CoordType > & | other | ) | const |
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator* | ( | const CoordT & | scale | ) | const |
Scalar multiplication.
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator*= | ( | const CoordT & | scale | ) |
Scalar multiplication.
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator+ | ( | const BaseVector< CoordT > & | other | ) | const |
Element-wise addition.
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator+= | ( | const BaseVector< CoordT > & | other | ) |
Element-wise addition.
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator- | ( | const BaseVector< CoordT > & | other | ) | const |
Element-wise subtraction.
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator-= | ( | const BaseVector< CoordT > & | other | ) |
Element-wise subtraction.
BaseVector<CoordT> lvr2::BaseVector< CoordT >::operator/ | ( | const CoordT & | scale | ) | const |
Scalar division.
BaseVector<CoordT>& lvr2::BaseVector< CoordT >::operator/= | ( | const CoordT & | scale | ) |
Scalar division.
bool lvr2::BaseVector< CoordT >::operator== | ( | const BaseVector< CoordT > & | other | ) | const |
CoordT& lvr2::BaseVector< CoordT >::operator[] | ( | const unsigned & | index | ) |
Indexed coordinate access (writing)
CoordT lvr2::BaseVector< CoordT >::operator[] | ( | const unsigned & | index | ) | const |
Indexed coordinate access (reading)
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.
CoordType lvr2::BaseVector< CoordT >::squaredDistanceFrom | ( | const BaseVector< CoordType > & | other | ) | const |
|
friend |
CoordT lvr2::BaseVector< CoordT >::x |
Definition at line 65 of file BaseVector.hpp.
CoordT lvr2::BaseVector< CoordT >::y |
Definition at line 66 of file BaseVector.hpp.
CoordT lvr2::BaseVector< CoordT >::z |
Definition at line 67 of file BaseVector.hpp.