vector Class Reference

Detailed Description
A vector class.The vector class incapsulates a classic C++ vector of three real values and treats them as a 3 dimensional mathematical vectors.
The most common operations between mathematical vectors (and some which involves scalars too) are defined.
Public Member Functions | |
| vector () | |
| default constructor | |
| vector (const real &x, const real &y, const real &z) | |
| constructs a vector from three values | |
| vector (vector &from, vector &to) | |
| constructs a vector from two other vectors | |
| vector (const vector &other) | |
| the copy constructor | |
| ~vector () | |
| the distructor | |
| real & | x () |
| accessor for the x component (can be used as l-value too) | |
| real & | y () |
| accessor for the y component (can be used as l-value too) | |
| real & | z () |
| accessor for the z component (can be used as l-value too) | |
| real | x () const |
| returns the x component (r-value only) | |
| real | y () const |
| returns the y component (r-value only) | |
| real | z () const |
| returns the z component (r-value only) | |
| vector & | operator= (const vector &other) |
| the assignment | |
| vector & | operator+= (const vector &other) |
| the sum & assign | |
| vector & | operator-= (const vector &other) |
| the subtract & assign | |
| vector & | operator *= (const real &fact) |
| the short multiply by a scalar factor & assign | |
| vector & | operator/= (const real &fact) |
| the short divide by a scalar factor & assign | |
| real & | operator[] (const int &index) |
| an "access like a C++ vector" | |
| operator double * () | |
| the conversion to a 3 double elements C++ vector | |
| real | normalize () |
| normalize the vector | |
| vector | normalized () const |
| normalized copy of the vector | |
| real | length () const |
| get the length of the vector | |
| real | length2 () const |
| get the squared length of the vector | |
| void | EpsilonCorrect (const vector &v) |
| if the vector is almost equal to the origin substitute it with v | |
Static Public Member Functions | |
| static int | howMany () |
| returns how many vector objects exists | |
Private Attributes | |
| real | vec [3] |
| the actual vector | |
Static Private Attributes | |
| static int | counter = 0 |
| counts how many vector objects are present | |
Friends | |
| int | operator== (const vector &v1, const vector &v2) |
| the equality operator | |
| int | operator!= (const vector &v1, const vector &v2) |
| the inequality operator | |
| vector | operator+ (const vector &v1, const vector &v2) |
| the sum | |
| vector | operator- (const vector &v1, const vector &v2) |
| the difference | |
| vector | operator- (const vector &v1) |
| the negation | |
| real | operator * (const vector &v1, const vector &v2) |
| the vector dot product | |
| vector | operator^ (const vector &v1, const vector &v2) |
| the vector cross product | |
| vector | operator * (const vector &v, const real &fact) |
| the multiply a vector by a scalar factor | |
| vector | operator * (const real &fact, const vector &v) |
| the multiply a scalar factor by a vector | |
| vector | operator/ (const vector &v, const real &fact) |
| the divide a vector by a scalar factor | |
| vector | Bisect (vector v0, vector v1) |
| returns the unit vector which halves the arc between v0 and v1 | |
| void | clamp (vector &vec, const real &low, const real &high) |
| clamps all the vector components between the given tresholds | |
| ostream & | operator<< (ostream &os, const vector &vect) |
| the print vector to C++ stream | |
Constructor & Destructor Documentation
| vector | ( | ) | [inline] |
default constructor
constructs a vector from three values
| ~vector | ( | ) | [inline] |
the distructor
Member Function Documentation
| real & x | ( | ) | [inline] |
accessor for the x component (can be used as l-value too)
| real & y | ( | ) | [inline] |
accessor for the y component (can be used as l-value too)
| real & z | ( | ) | [inline] |
accessor for the z component (can be used as l-value too)
| real x | ( | ) | const [inline] |
returns the x component (r-value only)
| real y | ( | ) | const [inline] |
returns the y component (r-value only)
| real z | ( | ) | const [inline] |
returns the z component (r-value only)
| real & operator[] | ( | const int & | index | ) | [inline] |
an "access like a C++ vector"
This operator redirects the access to the internal vector. It does make a range check on the index in debug builds trough the ANSI assert function. It can be used on both sides of an assignment.
- Returns:
- a reference to the requested element
- Parameters:
-
index the index which should be one of 0,1,2
| operator double * | ( | ) | [inline] |
| real normalize | ( | ) |
| vector normalized | ( | ) | const |
| void EpsilonCorrect | ( | const vector & | v | ) |
if the vector is almost equal to the origin substitute it with v
| int howMany | ( | ) | [inline, static] |
Friends And Related Function Documentation
the equality operator
This function check if all elements of v1 are equal to the corresponding elements of v2.
the inequality operator
This function check if some of the elements of v1 differs from the corresponding elements of v2.
the divide a vector by a scalar factor
returns the unit vector which halves the arc between v0 and v1
Member Data Documentation



