VectorNav C++ Library
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
vn::math::vec< tdim, T > Struct Template Reference

Template for a Euclidean vector. More...

#include <vector.h>

Public Member Functions

 vec ()
 Creates a new vector with uninitialized components.
 
 vec (T val)
 Creates new vector with components initialized to val. More...
 
T & operator[] (size_t index)
 Indexing into the vector's components. More...
 
const T & operator[] (size_t index) const
 Indexing into the vector's components. More...
 
vec operator- () const
 Negates the vector. More...
 
vecoperator+= (const vec &rhs)
 Adds a vector to this vector. More...
 
vecoperator-= (const vec &rhs)
 Subtracts a vector from this vector. More...
 
vecoperator*= (const T &rhs)
 Multiplies the vector by a scalar. More...
 
vecoperator/= (const T &rhs)
 Divides the vector by a scalar. More...
 
size_t dim () const
 The vector's dimension. More...
 
vec neg () const
 Negates the vector. More...
 
mag () const
 The vector's magnitude. More...
 
vec add (const vec &toAdd) const
 Adds a vector to this vector. More...
 
vec sub (const vec &to_sub) const
 Subtracts a vector from this vector. More...
 
vec mult (const double &scalar) const
 Multiplies the vector by a scalar. More...
 
vec div (const double &scalar) const
 Divides the vector by a scalar. More...
 
vec norm () const
 Normalizes the vector. More...
 
dot (const vec &rhs) const
 Computes the dot product of this and the provided vector. More...
 

Static Public Member Functions

static vec zero ()
 Vector with all of its components set to 0. More...
 
static vec one ()
 Vector with all of its components set to 1. More...
 

Public Attributes

c [tdim]
 The vector's components.
 

Detailed Description

template<size_t tdim, typename T = float>
struct vn::math::vec< tdim, T >

Template for a Euclidean vector.

Examples:
getting_started/main.cpp, math/main.cpp, and uart_protocol/main.cpp.

Constructor & Destructor Documentation

template<size_t tdim, typename T = float>
vn::math::vec< tdim, T >::vec ( val)
inlineexplicit

Creates new vector with components initialized to val.

Parameters
[in]valThe initialization value.

Member Function Documentation

template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::add ( const vec< tdim, T > &  toAdd) const
inline

Adds a vector to this vector.

Parameters
[in]toAddThe vector to add.
Returns
The resulting vector.
template<size_t tdim, typename T = float>
size_t vn::math::vec< tdim, T >::dim ( ) const
inline

The vector's dimension.

Returns
The vector's dimension.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::div ( const double &  scalar) const
inline

Divides the vector by a scalar.

Parameters
[in]scalarThe scalar value.
Returns
The divided vector.
template<size_t tdim, typename T = float>
T vn::math::vec< tdim, T >::dot ( const vec< tdim, T > &  rhs) const
inline

Computes the dot product of this and the provided vector.

Parameters
[in]rhsThe right-side vector.
Returns
The computed dot product.
template<size_t tdim, typename T = float>
T vn::math::vec< tdim, T >::mag ( ) const
inline

The vector's magnitude.

Returns
The magnitude.
Examples:
math/main.cpp.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::mult ( const double &  scalar) const
inline

Multiplies the vector by a scalar.

Parameters
[in]scalarThe scalar value.
Returns
The multiplied vector.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::neg ( ) const
inline

Negates the vector.

Returns
The negated vector.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::norm ( ) const
inline

Normalizes the vector.

Returns
The normalized vector.
Examples:
math/main.cpp.
template<size_t tdim, typename T = float>
static vec vn::math::vec< tdim, T >::one ( )
inlinestatic

Vector with all of its components set to 1.

Returns
The 1 vector.
template<size_t tdim, typename T = float>
vec& vn::math::vec< tdim, T >::operator*= ( const T &  rhs)
inline

Multiplies the vector by a scalar.

Parameters
[in]rhsThe scalar.
Returns
The multiplied vector.
template<size_t tdim, typename T = float>
vec& vn::math::vec< tdim, T >::operator+= ( const vec< tdim, T > &  rhs)
inline

Adds a vector to this vector.

Parameters
[in]rhsThe right-side vector.
Returns
The resulting vector.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::operator- ( ) const
inline

Negates the vector.

Returns
The negated vector.
template<size_t tdim, typename T = float>
vec& vn::math::vec< tdim, T >::operator-= ( const vec< tdim, T > &  rhs)
inline

Subtracts a vector from this vector.

Parameters
[in]rhsThe right-side vector.
Returns
The resulting vector.
template<size_t tdim, typename T = float>
vec& vn::math::vec< tdim, T >::operator/= ( const T &  rhs)
inline

Divides the vector by a scalar.

Parameters
[in]rhsThe scalar.
Returns
The divided vector.
template<size_t tdim, typename T = float>
T& vn::math::vec< tdim, T >::operator[] ( size_t  index)
inline

Indexing into the vector's components.

Parameters
[in]index0-based component index.
Exceptions
dimension_errorThe index exceeded the dimension of the vector.
template<size_t tdim, typename T = float>
const T& vn::math::vec< tdim, T >::operator[] ( size_t  index) const
inline

Indexing into the vector's components.

Parameters
[in]index0-based component index.
Exceptions
dimension_errorThe index exceeded the dimension of the vector.
template<size_t tdim, typename T = float>
vec vn::math::vec< tdim, T >::sub ( const vec< tdim, T > &  to_sub) const
inline

Subtracts a vector from this vector.

Parameters
[in]to_subThe vector to subtract from this.
Returns
The resulting vector.
template<size_t tdim, typename T = float>
static vec vn::math::vec< tdim, T >::zero ( )
inlinestatic

Vector with all of its components set to 0.

Returns
The 0 vector.

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