35 #ifndef LVR2_GEOMETRY_BASEVECTOR_H_ 36 #define LVR2_GEOMETRY_BASEVECTOR_H_ 41 #include <Eigen/Dense> 59 template <
typename CoordT>
73 BaseVector(
const CoordT &x,
const CoordT &y,
const CoordT &z)
136 if(!(this->x == 0 && this->y == 0 && this->z == 0))
138 auto len = this->
length();
179 template<
typename CollectionT>
189 template<
typename CollectionT>
208 CoordT
operator[](
const unsigned& index)
const;
219 template<
typename T,
typename S>
222 #endif // ifndef __NVCC__ 227 std::ostream& operator<<( std::ostream& os, const BaseVector<T>& v)
229 os <<
"Vec: [" << v.x <<
" " << v.y <<
" " << v.z <<
"]" << std::endl;
248 template<
typename CoordType,
typename Scalar = CoordType>
252 CoordType x = mat(0, 0) * normal.
x + mat(1, 0) * normal.
y + mat(2, 0) * normal.
z;
253 CoordType y = mat(0, 1) * normal.
x + mat(1, 1) * normal.
y + mat(2, 1) * normal.
z;
254 CoordType z = mat(0, 2) * normal.
x + mat(1, 2) * normal.
y + mat(2, 2) * normal.
z;
263 #endif // ifndef __NVCC__ 267 #include "lvr2/geometry/BaseVector.tcc" CoordT length() const
Returns the length of this vector.
BaseVector< CoordT > & operator-=(const BaseVector< CoordT > &other)
Element-wise subtraction.
typename Vec::CoordType CoordType
static BaseVector< CoordT > centroid(const CollectionT &points)
Returns the centroid of all points in the given collection.
BaseVector(const BaseVector &o)
BaseVector< CoordT > operator-(const BaseVector &other) const
Element-wise subtraction.
BaseVector< CoordT > operator*(const CoordT &scale) const
Scalar multiplication.
BaseVector< CoordT > operator/(const CoordT &scale) const
Scalar division.
BaseVector< CoordT > & operator*=(const CoordT &scale)
Scalar multiplication.
BaseVector< CoordT > cross(const BaseVector &other) const
Calculates the cross product between this and the given vector. Returns a new BaseVector instance...
bool operator==(const BaseVector &other) const
A vector guaranteed to be normalized (length = 1).
BaseVector()
Default constructs a null-vector.
CoordT distance2(const BaseVector &other) const
Calculates the squared distance to another vector.
CoordT length2() const
Returns the squared length of this vector.
Normal< CoordT > normalized() const
Returns a normalized version of this vector.
CoordType squaredDistanceFrom(const BaseVector< CoordType > &other) const
bool operator!=(const BaseVector &other) const
BaseVector< CoordT > operator+(const BaseVector &other) const
Element-wise addition.
BaseVector(const CoordT &x, const CoordT &y, const CoordT &z)
Builds a BaseVector with the given coordinates.
CoordT distance(const BaseVector &other) const
Calculates the distance to another vector.
BaseVector< CoordT > & operator/=(const CoordT &scale)
Scalar division.
BaseVector< CoordT > rotated(const BaseVector &n, const double &alpha) const
Calculates the rotated vector around an normal vector n with the rotation angle alpha.
CoordT dot(const BaseVector &other) const
Calculates the dot product between this and the given vector.
static BaseVector< CoordT > average(const CollectionT &vecs)
Returns the average of all vectors in the given collection.
A generic, weakly-typed vector.
CoordType distanceFrom(const BaseVector< CoordT > &other) const
CoordT operator[](const unsigned &index) const
Indexed coordinate access (reading)
BaseVector< CoordT > & operator+=(const BaseVector< CoordT > &other)
Element-wise addition.