fawkes::Vector Class Reference

A simple column vector. More...

#include <geometry/vector.h>

List of all members.

Public Member Functions

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

Friends

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


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:
size the dimension of the vector
data pointer to a float array
manage_memory if 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.

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

Copy constructor.

Parameters:
v another Vector

Definition at line 86 of file vector.cpp.

References m_data, and m_size.

fawkes::Vector::~Vector (  )  [virtual]

Destructor.

Definition at line 99 of file vector.cpp.


Member Function Documentation

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::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 *().

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

Get a reference to a certain element.

Parameters:
d index of the requested element
Returns:
reference to element at position d

Definition at line 159 of file vector.cpp.

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

Get a certain element.

Parameters:
d index of the requested element
Returns:
element at position d

Definition at line 146 of file vector.cpp.

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

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

Calculates the dot product of two vectors.

Parameters:
v the rhs Vector
Returns:
the scalar product

Definition at line 497 of file vector.cpp.

References get().

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

Multiply the vector with a scalar.

Parameters:
f the scalar
Returns:
scaled vector

Definition at line 307 of file vector.cpp.

References m_data.

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

In-place scalar multiplication.

Parameters:
f the 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:
cv the vector to be added
Returns:
sum vector

Definition at line 363 of file vector.cpp.

References m_data, and size().

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

In-place vector addition.

Parameters:
cv the 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:
cv the vector to be substracted
Returns:
diff vector

Definition at line 399 of file vector.cpp.

References m_data, and size().

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

In-place vector substraction.

Parameters:
cv the 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:
f the scalar
Returns:
scaled vector

Definition at line 335 of file vector.cpp.

References m_data.

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

In-place scalar division.

Parameters:
f the 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:
v the rhs vector
Returns:
reference to the lhs vector

Definition at line 435 of file vector.cpp.

References m_data, and m_size.

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

Comparison operator.

Parameters:
v the other vector
Returns:
true, if both vectors are equal

Definition at line 459 of file vector.cpp.

References m_data, and m_size.

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

Access operator.

Parameters:
d index of the requested element
Returns:
reference to the value at the given position

Definition at line 290 of file vector.cpp.

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

Access operator.

Parameters:
d index of the requested element
Returns:
the value at the given position

Definition at line 277 of file vector.cpp.

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

Prints the vector data to standard out.

Parameters:
name a string that is printed prior to the vector data

Definition at line 478 of file vector.cpp.

References get().

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

Set a certain element.

Parameters:
d index of the element
f the new value

Definition at line 176 of file vector.cpp.

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

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

Set a new size.

Parameters:
size the new size

Definition at line 120 of file vector.cpp.

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-(), and operator-=().

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

Convenience setter to set the first element.

Parameters:
x the new value of the first element

Definition at line 211 of file vector.cpp.

References set().

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.

References get().

float fawkes::Vector::x (  )  const

Convenience getter to obtain the first element.

Returns:
the first element

Definition at line 192 of file vector.cpp.

References get().

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

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

Convenience setter to set the second element.

Parameters:
y the new value of the second element

Definition at line 239 of file vector.cpp.

References set().

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.

References get().

float fawkes::Vector::y (  )  const

Convenience getter to obtain the second element.

Returns:
the second element

Definition at line 220 of file vector.cpp.

References get().

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

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

Convenience setter to set the third element.

Parameters:
z the new value of the third element

Definition at line 267 of file vector.cpp.

References set().

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.

References get().

float fawkes::Vector::z (  )  const

Convenience getter to obtain the third element.

Returns:
the third element

Definition at line 248 of file vector.cpp.

References get().

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


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:
stream the input stream
v the vector to be appended
Returns:
the resulting stream

Definition at line 513 of file vector.cpp.


The documentation for this class was generated from the following files:
Generated on Tue Feb 22 13:32:50 2011 for Fawkes API by  doxygen 1.4.7