#include <vector2.h>
Inheritance diagram for TVector2< T >:
Assignment | |
void | set (const T &value) throw () |
Assign from a scalar. | |
void | set (const T &vx, const T &vy) throw () |
Assign the vector components. | |
void | set (const TVector2 &vector) throw () |
Assign from another TVector2. | |
TVector2 & | operator= (const TVector2 &v) throw () |
Assignment operator. | |
TVector2 & | operator= (const T &value) throw () |
Assignment operator. | |
TVector2 & | operator= (const T *ptr) throw (Exception::NullPointer) |
Array assignment operator. | |
T | getLength () const throw () |
Return the length of the vector. | |
T | getSquareLength () const throw () |
Return the squared length of the vector. | |
TVector2 & | normalize () throw (Exception::DivisionByZero) |
Normalize the vector. | |
TVector2 & | negate () throw () |
Negate the vector. | |
T & | operator[] (Position position) throw (Exception::IndexOverflow) |
Mutable array-like access to the components. | |
const T & | operator[] (Position position) const throw (Exception::IndexOverflow) |
Constant array-like access to the components. | |
const TVector2 & | getZero () throw () |
Return a vector with all components 0. | |
const TVector2 & | getUnit () throw () |
Return a vector with all components 1. | |
Public Member Functions | |
Constructors and Destructors | |
TVector2 () throw () | |
Default constructor. | |
TVector2 (const T &value) throw () | |
Scalar constructor. | |
TVector2 (const T &vx, const T &vy) throw () | |
Detailed constructor. | |
TVector2 (const TVector2 &vector) throw () | |
Copy constructor. | |
TVector2 (const T *ptr) throw (Exception::NullPointer) | |
Array constructor. | |
virtual | ~TVector2 () throw () |
Destructor. | |
virtual void | clear () throw () |
Clear method The values are set to 0. | |
Persistence | |
virtual void | persistentWrite (PersistenceManager &pm, const char *name=0) const throw (Exception::GeneralException) |
Persistent writing. | |
virtual void | persistentRead (PersistenceManager &pm) throw (Exception::GeneralException) |
Persistent reading. | |
Arithmetic operators | |
const TVector2 & | operator+ () const throw () |
Positive sign. | |
TVector2 | operator- () const throw () |
Negative sign. | |
TVector2 | operator+ (const TVector2 &b) const throw () |
Addition. | |
TVector2 | operator- (const TVector2 &b) const throw () |
Subtraction. | |
TVector2 & | operator+= (const TVector2 &vector) throw () |
Add a vector to this vector. | |
TVector2 & | operator-= (const TVector2 &vector) throw () |
Subtract a vector from this vector. | |
TVector2 | operator * (const T &scalar) const throw () |
Scalar product. | |
TVector2 & | operator *= (const T &scalar) throw () |
Multiply by a scalar. | |
TVector2 | operator/ (const T &lambda) const throw (Exception::DivisionByZero) |
Fraction of a vector. | |
TVector2 & | operator/= (const T &lambda) throw (Exception::DivisionByZero) |
Divide a vector by a scalar. | |
T | operator * (const TVector2 &vector) const throw () |
Dot product. | |
Geometric properties | |
T | getDistance (const TVector2 &vector) const throw () |
Return the distance to another vector. | |
T | getSquareDistance (const TVector2 &vector) const throw () |
Return the squared distance to another vector. | |
Predicates | |
bool | operator== (const TVector2 &vector) const throw () |
Equality operator. | |
bool | operator!= (const TVector2 &vector) const throw () |
Inequality operator. | |
bool | isZero () const throw () |
Zero predicate. | |
bool | isOrthogonalTo (TVector2 &vector) const throw () |
Orthogonality predicate. | |
Debugging and Diagnostics | |
void | dump (std::ostream &s=std::cout, Size depth=0) const throw () |
Internal state dump. | |
bool | isValid () const throw () |
Test if instance is valid. | |
Public Attributes | |
Vector components | |
For easier access, the two components of the vector are public members. | |
T | x |
x component of the vector | |
T | y |
y component of the vector |
|
Default constructor.
This method creates a new TVector2 object. The two components are initialized to |
|
Scalar constructor.
Create a new vector with all components set to the same
|
|
Detailed constructor.
Create a new TVector2 object from two variables of type
|
|
Copy constructor. Create a new TVector2 object from another.
|
|
Array constructor.
This constructor creates a TVector3 object from the first two elements pointed to by
|
|
Destructor. Destructs the TVector2 object. As there are no dynamic data structures, nothing happens. |
|
Clear method The values are set to 0.
Reimplemented from Object. |
|
Internal state dump. Dump the current internal state of {*this} to the output ostream s with dumping depth depth .
|
|
Return the distance to another vector.
|
|
Return the length of the vector. The length of the vector is calculated as .
|
|
Return the squared distance to another vector.
|
|
Return the squared length of the vector. This method avoids the square root needed in getLength, so this method is preferred if possible.
|
|
Return a vector with all components 1.
|
|
Return a vector with all components 0.
|
|
Orthogonality predicate.
|
|
Test if instance is valid. Always returns true.
Reimplemented from Object. |
|
Zero predicate. The function Maths::isZero is used to compare the values with zero. Maths::isZero |
|
Negate the vector. Negate the two components of the vector
|
|
Normalize the vector. The vector is scaled with its length: .
|
|
Dot product.
Return the dot product of this vector and |
|
Scalar product.
Return
|
|
Multiply by a scalar.
Multiply all components of the vector by a
|
|
Inequality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual
|
|
|
|
Positive sign.
|
|
Add a vector to this vector.
Add the components of
|
|
|
|
Negative sign.
|
|
Subtract a vector from this vector.
|
|
Fraction of a vector.
Return
|
|
Divide a vector by a scalar.
|
|
Array assignment operator. Assigns the first two elements of an array to the vector components.
|
|
Assignment operator. Assign a constant value to the two vector components.
|
|
Assignment operator. Assign the vector components from another vector.
|
|
Equality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual
|
|
Constant array-like access to the components.
|
|
Mutable array-like access to the components.
|
|
Persistent reading. Reads a TVector2 object from a persistent stream.
Reimplemented from PersistentObject. |
|
Persistent writing. Writes a TVector2 object to a persistent stream.
Reimplemented from PersistentObject. |
|
Assign from another TVector2.
|
|
Assign the vector components.
|
|
Assign from a scalar.
Assign
|