Fawkes API
Fawkes Development Version
|
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... | |
Vector & | operator*= (const float &f) |
In-place scalar multiplication. More... | |
Vector | operator/ (const float &f) const |
Divide every element of the vector by a scalar. More... | |
Vector & | operator/= (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... | |
Vector & | operator+= (const Vector &v) |
In-place vector addition. More... | |
Vector | operator- (const Vector &v) const |
Substract two vectors. More... | |
Vector & | operator-= (const Vector &v) |
In-place vector substraction. More... | |
Vector & | operator= (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... | |
fawkes::Vector::Vector | ( | unsigned int | size = 3 , |
float * | data = 0 , |
||
bool | manage_memory = true |
||
) |
Constructor.
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.
References size().
fawkes::Vector::Vector | ( | const Vector & | v | ) |
|
virtual |
Destructor.
Definition at line 99 of file vector.cpp.
|
inline |
Get pointer to the internal data container.
Definition at line 41 of file vector.h.
Referenced by fawkes::Matrix::operator*().
|
inline |
float fawkes::Vector::get | ( | unsigned int | d | ) | const |
Get a certain element.
d | index of the requested element |
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.
d | index of the requested element |
Definition at line 159 of file vector.cpp.
Vector fawkes::Vector::operator* | ( | const float & | f | ) | const |
Multiply the vector with a scalar.
f | the scalar |
Definition at line 307 of file vector.cpp.
float fawkes::Vector::operator* | ( | const Vector & | v | ) | const |
Calculates the dot product of two vectors.
v | the rhs Vector |
Definition at line 497 of file vector.cpp.
References get().
Vector & fawkes::Vector::operator*= | ( | const float & | f | ) |
In-place scalar multiplication.
f | the scalar |
Definition at line 322 of file vector.cpp.
Adds two vectors.
cv | the vector to be added |
Definition at line 363 of file vector.cpp.
References size().
In-place vector addition.
cv | the vector to be added |
Definition at line 382 of file vector.cpp.
References size().
Substract two vectors.
cv | the vector to be substracted |
Definition at line 399 of file vector.cpp.
References size().
In-place vector substraction.
cv | the vector to be substracted |
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.
f | the scalar |
Definition at line 335 of file vector.cpp.
Vector & fawkes::Vector::operator/= | ( | const float & | f | ) |
In-place scalar division.
f | the scalar |
Definition at line 350 of file vector.cpp.
Assignment operator.
v | the rhs vector |
Definition at line 435 of file vector.cpp.
bool fawkes::Vector::operator== | ( | const Vector & | v | ) |
Comparison operator.
v | the other vector |
Definition at line 459 of file vector.cpp.
float fawkes::Vector::operator[] | ( | unsigned int | d | ) | const |
Access operator.
d | index of the requested element |
Definition at line 277 of file vector.cpp.
float & fawkes::Vector::operator[] | ( | unsigned int | d | ) |
Access operator.
d | index of the requested element |
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.
name | a 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.
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(), 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.
size | the new size |
Definition at line 120 of file vector.cpp.
References size().
unsigned int fawkes::Vector::size | ( | ) | const |
Get the 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.
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.
Definition at line 201 of file vector.cpp.
void fawkes::Vector::x | ( | float | x | ) |
Convenience setter to set the first element.
x | the 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.
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.
Definition at line 229 of file vector.cpp.
void fawkes::Vector::y | ( | float | y | ) |
Convenience setter to set the second element.
y | the 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.
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.
Definition at line 257 of file vector.cpp.
void fawkes::Vector::z | ( | float | z | ) |
Convenience setter to set the third element.
z | the new value of the third element |
Definition at line 267 of file vector.cpp.
References set().
|
friend |
Appends the components of the Vector to the ostream.
stream | the input stream |
v | the vector to be appended |
stream | the input stream |
v | the vector to be appended |
Definition at line 513 of file vector.cpp.