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

Vector with 3 component specialization. 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...
 
 vec (const T &x_val, const T &y_val, const T &z_val)
 Creates a new vector with its components initialized to the provided values. 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...
 
vec< 3, T > cross (const vec< 3, T > &rhs) const
 Computes the cross 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...
 
static vec unitX ()
 Unit vector pointing in the X (0-component) direction. More...
 
static vec unitY ()
 Unit vector pointing in the Y (1-component) direction. More...
 
static vec unitZ ()
 Unit vector pointing in the Z (2-component) direction. More...
 

Public Attributes

union vn::math::vec< 3, T >:: { ... }  
 
x
 X (0-component).
 
y
 Y (1-component).
 
z
 Z (2-component).
 
r
 Red (0-component).
 
g
 Green (1-component).
 
b
 Blue (2-component).
 
c [3]
 The vector's components.
 

Detailed Description

template<typename T>
struct vn::math::vec< 3, T >

Vector with 3 component specialization.

Constructor & Destructor Documentation

template<typename T >
vn::math::vec< 3, T >::vec ( val)
inlineexplicit

Creates new vector with components initialized to val.

Parameters
[in]valThe initialization value.
template<typename T >
vn::math::vec< 3, T >::vec ( const T &  x_val,
const T &  y_val,
const T &  z_val 
)
inline

Creates a new vector with its components initialized to the provided values.

Parameters
[in]x_valThe x value.
[in]y_valThe y value.
[in]z_valThe z value.

Member Function Documentation

template<typename T >
vec vn::math::vec< 3, T >::add ( const vec< 3, T > &  toAdd) const
inline

Adds a vector to this vector.

Parameters
[in]toAddThe vector to add.
Returns
The resulting vector.
template<typename T >
vec<3, T> vn::math::vec< 3, T >::cross ( const vec< 3, T > &  rhs) const
inline

Computes the cross product of this and the provided vector.

Parameters
[in]rhsThe right-side vector.
Returns
The computed cross product.
Exceptions
dimension_errorThe dimension of the vector is not 3.
template<typename T >
size_t vn::math::vec< 3, T >::dim ( ) const
inline

The vector's dimension.

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

Divides the vector by a scalar.

Parameters
[in]scalarThe scalar value.
Returns
The divided vector.
template<typename T >
T vn::math::vec< 3, T >::dot ( const vec< 3, 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<typename T >
T vn::math::vec< 3, T >::mag ( ) const
inline

The vector's magnitude.

Returns
The magnitude.
template<typename T >
vec vn::math::vec< 3, T >::mult ( const double &  scalar) const
inline

Multiplies the vector by a scalar.

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

Negates the vector.

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

Normalizes the vector.

Returns
The normalized vector.
template<typename T >
static vec vn::math::vec< 3, T >::one ( )
inlinestatic

Vector with all of its components set to 1.

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

Multiplies the vector by a scalar.

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

Adds a vector to this vector.

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

Negates the vector.

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

Subtracts a vector from this vector.

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

Divides the vector by a scalar.

Parameters
[in]rhsThe scalar.
Returns
The divided vector.
template<typename T >
T& vn::math::vec< 3, 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<typename T >
const T& vn::math::vec< 3, 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<typename T >
vec vn::math::vec< 3, T >::sub ( const vec< 3, 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<typename T >
static vec vn::math::vec< 3, T >::unitX ( )
inlinestatic

Unit vector pointing in the X (0-component) direction.

Returns
The unit vector.
template<typename T >
static vec vn::math::vec< 3, T >::unitY ( )
inlinestatic

Unit vector pointing in the Y (1-component) direction.

Returns
The unit vector.
template<typename T >
static vec vn::math::vec< 3, T >::unitZ ( )
inlinestatic

Unit vector pointing in the Z (2-component) direction.

Returns
The unit vector.
template<typename T >
static vec vn::math::vec< 3, 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: