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 53 of file vector.cpp.

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

Copy constructor.

Parameters:
v another Vector

Definition at line 79 of file vector.cpp.

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

Destructor.

Definition at line 92 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
Author:
Daniel Beck

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 152 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 139 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::operator* ( const Vector v  )  const

Calculates the dot product of two vectors.

Parameters:
v the rhs Vector
Returns:
the scalar product

Definition at line 490 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 300 of file vector.cpp.

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

In-place scalar multiplication.

Parameters:
f the scalar
Returns:
reference to the scaled vector

Definition at line 315 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 356 of file vector.cpp.

References 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 375 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 392 of file vector.cpp.

References 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 411 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 328 of file vector.cpp.

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

In-place scalar division.

Parameters:
f the scalar
Returns:
reference to the scaled vector

Definition at line 343 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 428 of file vector.cpp.

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

Comparison operator.

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

Definition at line 452 of file vector.cpp.

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 283 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 270 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 471 of file vector.cpp.

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 169 of file vector.cpp.

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

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

Set a new size.

Parameters:
size the new size

Definition at line 113 of file vector.cpp.

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

Get the number of elements.

Returns:
number of elements

Definition at line 104 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 204 of file vector.cpp.

float & fawkes::Vector::x (  ) 

Convenience getter to obtain a reference to the first element.

Returns:
reference to the first element

Definition at line 194 of file vector.cpp.

float fawkes::Vector::x (  )  const

Convenience getter to obtain the first element.

Returns:
the first element

Definition at line 185 of file vector.cpp.

Referenced by ProjectiveCam::get_GPA_image_coord(), and 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 232 of file vector.cpp.

float & fawkes::Vector::y (  ) 

Convenience getter to obtain a reference to the second element.

Returns:
reference to the second element

Definition at line 222 of file vector.cpp.

float fawkes::Vector::y (  )  const

Convenience getter to obtain the second element.

Returns:
the second element

Definition at line 213 of file vector.cpp.

Referenced by ProjectiveCam::get_GPA_image_coord(), and 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 260 of file vector.cpp.

float & fawkes::Vector::z (  ) 

Convenience getter to obtain a reference to the third element.

Returns:
reference to the third element

Definition at line 250 of file vector.cpp.

float fawkes::Vector::z (  )  const

Convenience getter to obtain the third element.

Returns:
the third element

Definition at line 241 of file vector.cpp.

Referenced by ProjectiveCam::get_GPA_image_coord(), and 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 508 of file vector.cpp.


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