Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fawkes::Vector Class Reference

A simple column vector. More...

#include <>>

Public Member Functions

 Vector (unsigned int size=3, float *elems=0, bool manage_memory=true)
 Constructor. More...
 
 Vector (const Vector &v)
 Copy constructor. More...
 
virtual ~Vector ()
 Destructor. More...
 
unsigned int size () const
 Get the number of elements. More...
 
void set_size (unsigned int size)
 Set a new size. More...
 
float * data_ptr ()
 Get pointer to the internal data container. More...
 
const float * data_ptr () const
 Get pointer to the internal data container. More...
 
float get (unsigned int d) const
 Get a certain element. More...
 
float & get (unsigned int d)
 Get a reference to a certain element. More...
 
void set (unsigned int d, float v)
 Set a certain element. More...
 
float x () const
 Convenience getter to obtain the first element. More...
 
float & x ()
 Convenience getter to obtain a reference to the first element. More...
 
void x (float x)
 Convenience setter to set the first element. More...
 
float y () const
 Convenience getter to obtain the second element. More...
 
float & y ()
 Convenience getter to obtain a reference to the second element. More...
 
void y (float y)
 Convenience setter to set the second element. More...
 
float z () const
 Convenience getter to obtain the third element. More...
 
float & z ()
 Convenience getter to obtain a reference to the third element. More...
 
void z (float z)
 Convenience setter to set the third element. More...
 
float operator[] (unsigned int d) const
 Access operator. More...
 
float & operator[] (unsigned int d)
 Access operator. More...
 
Vector operator* (const float &f) const
 Multiply the vector with a scalar. More...
 
Vectoroperator*= (const float &f)
 In-place scalar multiplication. More...
 
Vector operator/ (const float &f) const
 Divide every element of the vector by a scalar. More...
 
Vectoroperator/= (const float &f)
 In-place scalar division. More...
 
float operator* (const Vector &v) const
 Calculates the dot product of two vectors. More...
 
Vector operator+ (const Vector &v) const
 Adds two vectors. More...
 
Vectoroperator+= (const Vector &v)
 In-place vector addition. More...
 
Vector operator- (const Vector &v) const
 Substract two vectors. More...
 
Vectoroperator-= (const Vector &v)
 In-place vector substraction. More...
 
Vectoroperator= (const Vector &v)
 Assignment operator. More...
 
bool operator== (const Vector &v)
 Comparison operator. More...
 
void print_info (const char *name=0) const
 Prints the vector data to standard out. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const Vector &v)
 Appends the components of the Vector to the ostream. More...
 

Detailed Description

A simple column vector.

Definition at line 31 of file vector.h.

Constructor & Destructor Documentation

fawkes::Vector::Vector ( unsigned int  size = 3,
float *  data = 0,
bool  manage_memory = true 
)

Constructor.

Parameters
sizethe dimension of the vector
datapointer to a float array
manage_memoryif true, the Vector will manage its memory on its own, else it will not allocate new memory but works with the provided array

Definition at line 60 of file vector.cpp.

References size().

fawkes::Vector::Vector ( const Vector v)

Copy constructor.

Parameters
vanother Vector

Definition at line 86 of file vector.cpp.

fawkes::Vector::~Vector ( )
virtual

Destructor.

Definition at line 99 of file vector.cpp.

Member Function Documentation

float * fawkes::Vector::data_ptr ( )
inline

Get pointer to the internal data container.

Returns
pointer to the internal data container

Definition at line 41 of file vector.h.

Referenced by fawkes::Matrix::operator*().

const float * fawkes::Vector::data_ptr ( ) const
inline

Get pointer to the internal data container.

Returns
pointer to the internal data container

Definition at line 42 of file vector.h.

float fawkes::Vector::get ( unsigned int  d) const

Get a certain element.

Parameters
dindex of the requested element
Returns
element at position d

Definition at line 146 of file vector.cpp.

Referenced by operator*(), fawkes::operator<<(), fawkes::HomCoord::w(), fawkes::HomCoord::x(), fawkes::HomCoord::y(), and fawkes::HomCoord::z().

float & fawkes::Vector::get ( unsigned int  d)

Get a reference to a certain element.

Parameters
dindex of the requested element
Returns
reference to element at position d

Definition at line 159 of file vector.cpp.

Vector fawkes::Vector::operator* ( const float &  f) const

Multiply the vector with a scalar.

Parameters
fthe scalar
Returns
scaled vector

Definition at line 307 of file vector.cpp.

float fawkes::Vector::operator* ( const Vector v) const

Calculates the dot product of two vectors.

Parameters
vthe rhs Vector
Returns
the scalar product

Definition at line 497 of file vector.cpp.

References get().

Vector & fawkes::Vector::operator*= ( const float &  f)

In-place scalar multiplication.

Parameters
fthe scalar
Returns
reference to the scaled vector

Definition at line 322 of file vector.cpp.

Vector fawkes::Vector::operator+ ( const Vector cv) const

Adds two vectors.

Parameters
cvthe vector to be added
Returns
sum vector

Definition at line 363 of file vector.cpp.

References size().

Vector & fawkes::Vector::operator+= ( const Vector cv)

In-place vector addition.

Parameters
cvthe vector to be added
Returns
reference to the sum vector

Definition at line 382 of file vector.cpp.

References size().

Vector fawkes::Vector::operator- ( const Vector cv) const

Substract two vectors.

Parameters
cvthe vector to be substracted
Returns
diff vector

Definition at line 399 of file vector.cpp.

References size().

Vector & fawkes::Vector::operator-= ( const Vector cv)

In-place vector substraction.

Parameters
cvthe vector to be substracted
Returns
reference to the diff vector

Definition at line 418 of file vector.cpp.

References size().

Vector fawkes::Vector::operator/ ( const float &  f) const

Divide every element of the vector by a scalar.

Parameters
fthe scalar
Returns
scaled vector

Definition at line 335 of file vector.cpp.

Vector & fawkes::Vector::operator/= ( const float &  f)

In-place scalar division.

Parameters
fthe scalar
Returns
reference to the scaled vector

Definition at line 350 of file vector.cpp.

Vector & fawkes::Vector::operator= ( const Vector v)

Assignment operator.

Parameters
vthe rhs vector
Returns
reference to the lhs vector

Definition at line 435 of file vector.cpp.

bool fawkes::Vector::operator== ( const Vector v)

Comparison operator.

Parameters
vthe other vector
Returns
true, if both vectors are equal

Definition at line 459 of file vector.cpp.

float fawkes::Vector::operator[] ( unsigned int  d) const

Access operator.

Parameters
dindex of the requested element
Returns
the value at the given position

Definition at line 277 of file vector.cpp.

float & fawkes::Vector::operator[] ( unsigned int  d)

Access operator.

Parameters
dindex of the requested element
Returns
reference to the value at the given position

Definition at line 290 of file vector.cpp.

void fawkes::Vector::print_info ( const char *  name = 0) const

Prints the vector data to standard out.

Parameters
namea string that is printed prior to the vector data

Definition at line 478 of file vector.cpp.

void fawkes::Vector::set ( unsigned int  d,
float  f 
)

Set a certain element.

Parameters
dindex of the element
fthe new value

Definition at line 176 of file vector.cpp.

Referenced by firevision::ProjectiveCam::get_GPA_image_coord(), fawkes::HomCoord::HomCoord(), fawkes::HomCoord::w(), fawkes::HomCoord::x(), x(), fawkes::HomCoord::y(), y(), fawkes::HomCoord::z(), and z().

void fawkes::Vector::set_size ( unsigned int  size)

Set a new size.

Parameters
sizethe new size

Definition at line 120 of file vector.cpp.

References size().

unsigned int fawkes::Vector::size ( ) const

Get the number of elements.

Returns
number of elements

Definition at line 111 of file vector.cpp.

Referenced by fawkes::Matrix::operator*(), operator+(), operator+=(), operator-(), operator-=(), set_size(), and Vector().

float fawkes::Vector::x ( ) const

Convenience getter to obtain the first element.

Returns
the first element

Definition at line 192 of file vector.cpp.

Referenced by firevision::ProjectiveCam::get_GPA_image_coord(), firevision::ProjectiveCam::get_GPA_world_coord(), and fawkes::OpenRaveEnvironment::rotate_object().

float & fawkes::Vector::x ( )

Convenience getter to obtain a reference to the first element.

Returns
reference to the first element

Definition at line 201 of file vector.cpp.

void fawkes::Vector::x ( float  x)

Convenience setter to set the first element.

Parameters
xthe new value of the first element

Definition at line 211 of file vector.cpp.

References set().

float fawkes::Vector::y ( ) const

Convenience getter to obtain the second element.

Returns
the second element

Definition at line 220 of file vector.cpp.

Referenced by firevision::ProjectiveCam::get_GPA_image_coord(), firevision::ProjectiveCam::get_GPA_world_coord(), and fawkes::OpenRaveEnvironment::rotate_object().

float & fawkes::Vector::y ( )

Convenience getter to obtain a reference to the second element.

Returns
reference to the second element

Definition at line 229 of file vector.cpp.

void fawkes::Vector::y ( float  y)

Convenience setter to set the second element.

Parameters
ythe new value of the second element

Definition at line 239 of file vector.cpp.

References set().

float fawkes::Vector::z ( ) const

Convenience getter to obtain the third element.

Returns
the third element

Definition at line 248 of file vector.cpp.

Referenced by firevision::ProjectiveCam::get_GPA_image_coord(), firevision::ProjectiveCam::get_GPA_world_coord(), and fawkes::OpenRaveEnvironment::rotate_object().

float & fawkes::Vector::z ( )

Convenience getter to obtain a reference to the third element.

Returns
reference to the third element

Definition at line 257 of file vector.cpp.

void fawkes::Vector::z ( float  z)

Convenience setter to set the third element.

Parameters
zthe new value of the third element

Definition at line 267 of file vector.cpp.

References set().

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  stream,
const Vector v 
)
friend

Appends the components of the Vector to the ostream.

Parameters
streamthe input stream
vthe vector to be appended
Returns
the resulting stream
Parameters
streamthe input stream
vthe vector to be appended
Returns
the resulting stream
Author
Daniel Beck

Definition at line 513 of file vector.cpp.


The documentation for this class was generated from the following files: