#include <BALL/MATHS/vector2.h>
Public Member Functions | |
Constructors and Destructors | |
TVector2 () | |
TVector2 (const T &value) | |
TVector2 (const T &vx, const T &vy) | |
TVector2 (const TVector2 &vector) | |
TVector2 (const T *ptr) throw (Exception::NullPointer) | |
virtual | ~TVector2 () |
virtual void | clear () |
Persistence | |
virtual void | persistentWrite (PersistenceManager &pm, const char *name=0) const throw (Exception::GeneralException) |
virtual void | persistentRead (PersistenceManager &pm) throw (Exception::GeneralException) |
Arithmetic operators | |
const TVector2 & | operator+ () const |
TVector2 | operator- () const |
TVector2 | operator+ (const TVector2 &b) const |
TVector2 | operator- (const TVector2 &b) const |
TVector2 & | operator+= (const TVector2 &vector) |
TVector2 & | operator-= (const TVector2 &vector) |
TVector2 | operator* (const T &scalar) const |
TVector2 & | operator*= (const T &scalar) |
TVector2 | operator/ (const T &lambda) const throw (Exception::DivisionByZero) |
TVector2 & | operator/= (const T &lambda) throw (Exception::DivisionByZero) |
T | operator* (const TVector2 &vector) const |
Geometric properties | |
T | getDistance (const TVector2 &vector) const |
T | getSquareDistance (const TVector2 &vector) const |
Predicates | |
bool | operator== (const TVector2 &vector) const |
bool | operator!= (const TVector2 &vector) const |
bool | isZero () const |
bool | isOrthogonalTo (TVector2 &vector) const |
Debugging and Diagnostics | |
void | dump (std::ostream &s=std::cout, Size depth=0) const |
bool | isValid () const |
Public Attributes | |
Vector components | |
For easier access, the two components of the vector are public members. | |
T | x |
T | y |
Assignment | |
void | set (const T &value) |
void | set (const T &vx, const T &vy) |
void | set (const TVector2 &vector) |
TVector2 & | operator= (const TVector2 &v) |
TVector2 & | operator= (const T &value) |
TVector2 & | operator= (const T *ptr) throw (Exception::NullPointer) |
T | getLength () const |
T | getSquareLength () const |
TVector2 & | normalize () throw (Exception::DivisionByZero) |
TVector2 & | negate () |
T & | operator[] (Position position) throw (Exception::IndexOverflow) |
const T & | operator[] (Position position) const throw (Exception::IndexOverflow) |
static const TVector2 & | getZero () |
static const TVector2 & | getUnit () |
Generic Two-Dimensional Vector.
BALL::TVector2< T >::TVector2 | ( | ) | [inline] |
Default constructor. This method creates a new TVector2 object. The two components are initialized to (T)0
.
BALL::TVector2< T >::TVector2 | ( | const T & | value | ) | [inline, explicit] |
Scalar constructor. Create a new vector with all components set to the same value
.
value | the value of all components |
BALL::TVector2< T >::TVector2 | ( | const T & | vx, | |
const T & | vy | |||
) | [inline] |
Detailed constructor. Create a new TVector2 object from two variables of type T
.
vx | assigned to x | |
vy | assigned to y |
BALL::TVector2< T >::TVector2 | ( | const TVector2< T > & | vector | ) | [inline] |
BALL_INLINE BALL::TVector2< T >::TVector2 | ( | const T * | ptr | ) | throw (Exception::NullPointer) [inline] |
Array constructor. This constructor creates a TVector3 object from the first two elements pointed to by ptr
.
ptr | the array to construct from |
NullPointer | if ptr == 0 |
BALL::TVector2< T >::~TVector2 | ( | ) | [inline, virtual] |
Destructor. Destructs the TVector2 object. As there are no dynamic data structures, nothing happens.
void BALL::TVector2< T >::clear | ( | ) | [inline, virtual] |
Clear method The values are set to 0.
Reimplemented from BALL::Object.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
void BALL::TVector2< T >::dump | ( | std::ostream & | s = std::cout , |
|
Size | depth = 0 | |||
) | const [inline] |
Internal state dump. Dump the current internal state of {*this} to the output ostream s with dumping depth depth .
s | - output stream where to output the internal state of {*this} | |
depth | - the dumping depth |
References BALL_DUMP_DEPTH, BALL_DUMP_HEADER, BALL_DUMP_STREAM_PREFIX, BALL_DUMP_STREAM_SUFFIX, BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE T BALL::TVector2< T >::getDistance | ( | const TVector2< T > & | vector | ) | const [inline] |
Return the distance to another vector.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE T BALL::TVector2< T >::getLength | ( | ) | const [inline] |
Return the length of the vector. The length of the vector is calculated as .
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE T BALL::TVector2< T >::getSquareDistance | ( | const TVector2< T > & | vector | ) | const [inline] |
Return the squared distance to another vector.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE T BALL::TVector2< T >::getSquareLength | ( | ) | const [inline] |
Return the squared length of the vector. This method avoids the square root needed in getLength, so this method is preferred if possible.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE const TVector2< T > & BALL::TVector2< T >::getUnit | ( | ) | [inline, static] |
Return a vector with all components 1.
BALL_INLINE const TVector2< T > & BALL::TVector2< T >::getZero | ( | ) | [inline, static] |
Return a vector with all components 0.
BALL_INLINE bool BALL::TVector2< T >::isOrthogonalTo | ( | TVector2< T > & | vector | ) | const [inline] |
Orthogonality predicate.
References BALL::TVector2< T >::isZero().
BALL_INLINE bool BALL::TVector2< T >::isValid | ( | ) | const [inline, virtual] |
BALL_INLINE bool BALL::TVector2< T >::isZero | ( | ) | const [inline] |
Zero predicate. The function Maths::isZero is used to compare the values with zero. Maths::isZero
References BALL::Maths::isZero(), BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
Referenced by BALL::TVector2< T >::isOrthogonalTo().
TVector2< T > & BALL::TVector2< T >::negate | ( | ) | [inline] |
Negate the vector. Negate the two components of the vector
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
TVector2< T > & BALL::TVector2< T >::normalize | ( | ) | throw (Exception::DivisionByZero) [inline] |
Normalize the vector. The vector is scaled with its length: .
DivisionByZero | if the length of the vector is 0 |
References BALL::Maths::isZero(), BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE bool BALL::TVector2< T >::operator!= | ( | const TVector2< T > & | vector | ) | const [inline] |
Inequality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual
References BALL::Maths::isNotEqual(), BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE T BALL::TVector2< T >::operator* | ( | const TVector2< T > & | vector | ) | const [inline] |
Dot product. Return the dot product of this vector and vector
.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > BALL::TVector2< T >::operator* | ( | const T & | scalar | ) | const [inline] |
Scalar product. Return TVector2(x * scalar, y * scalar)
. The symmetric case is a global function.
scalar,the | scalar to multiply by |
scalar
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator*= | ( | const T & | scalar | ) | [inline] |
Multiply by a scalar. Multiply all components of the vector by a scalar
value.
scalar | the to multiply by |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > BALL::TVector2< T >::operator+ | ( | const TVector2< T > & | b | ) | const [inline] |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE const TVector2< T > & BALL::TVector2< T >::operator+ | ( | ) | const [inline] |
Positive sign.
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator+= | ( | const TVector2< T > & | vector | ) | [inline] |
Add a vector to this vector. Add the components of vector
to this vector.
vector | the vector to add |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > BALL::TVector2< T >::operator- | ( | const TVector2< T > & | b | ) | const [inline] |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > BALL::TVector2< T >::operator- | ( | ) | const [inline] |
Negative sign.
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator-= | ( | const TVector2< T > & | vector | ) | [inline] |
Subtract a vector from this vector.
vector | the vector to subtract |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
TVector2< T > BALL::TVector2< T >::operator/ | ( | const T & | lambda | ) | const throw (Exception::DivisionByZero) [inline] |
Fraction of a vector. Return TVector2(x / lambda, y / lambda)
.
lambda | the scalar value to divide by |
Exception::DivisionByZero | if lambda == (T)0 |
TVector2< T > & BALL::TVector2< T >::operator/= | ( | const T & | lambda | ) | throw (Exception::DivisionByZero) [inline] |
Divide a vector by a scalar.
lambda | the scalar value to divide by |
Exception::DivisionByZero | if lambda == (T)0 |
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator= | ( | const T * | ptr | ) | throw (Exception::NullPointer) [inline] |
Array assignment operator. Assigns the first two elements of an array to the vector components.
ptr | the array |
NullPointer | if ptr == 0 |
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator= | ( | const T & | value | ) | [inline] |
Assignment operator. Assign a constant value to the two vector components.
value | the constant to assign to x, y |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE TVector2< T > & BALL::TVector2< T >::operator= | ( | const TVector2< T > & | v | ) | [inline] |
Assignment operator. Assign the vector components from another vector.
v | the vector to assign from |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE bool BALL::TVector2< T >::operator== | ( | const TVector2< T > & | vector | ) | const [inline] |
Equality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual
References BALL::Maths::isEqual(), BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE const T & BALL::TVector2< T >::operator[] | ( | Position | position | ) | const throw (Exception::IndexOverflow) [inline] |
Constant array-like access to the components.
Exception::IndexOverflow | if index > 1 |
BALL_INLINE T & BALL::TVector2< T >::operator[] | ( | Position | position | ) | throw (Exception::IndexOverflow) [inline] |
Mutable array-like access to the components.
Exception::IndexOverflow | if index > 1 |
void BALL::TVector2< T >::persistentRead | ( | PersistenceManager & | pm | ) | throw (Exception::GeneralException) [inline, virtual] |
Persistent reading. Reads a TVector2 object from a persistent stream.
pm | the persistence manager |
Reimplemented from BALL::PersistentObject.
void BALL::TVector2< T >::persistentWrite | ( | PersistenceManager & | pm, | |
const char * | name = 0 | |||
) | const throw (Exception::GeneralException) [inline, virtual] |
Persistent writing. Writes a TVector2 object to a persistent stream.
pm | the persistence manager |
Reimplemented from BALL::PersistentObject.
BALL_INLINE void BALL::TVector2< T >::set | ( | const TVector2< T > & | vector | ) | [inline] |
Assign from another TVector2.
vector | the TVector2 object to assign from |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE void BALL::TVector2< T >::set | ( | const T & | vx, | |
const T & | vy | |||
) | [inline] |
Assign the vector components.
vx | the new x component | |
vy | the new y component |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
BALL_INLINE void BALL::TVector2< T >::set | ( | const T & | value | ) | [inline] |
Assign from a scalar. Assign value
to the two vector components.
value | the new value of the components |
References BALL::TVector2< T >::x, and BALL::TVector2< T >::y.
Referenced by BALL::TRegularData2D< ValueType >::clear(), BALL::TFFT2D< ComplexTraits >::getGridCoordinates(), and BALL::operator<<().
T BALL::TVector2< T >::x |
x component of the vector
Referenced by BALL::TVector2< T >::clear(), BALL::TVector2< T >::dump(), BALL::TVector2< T >::getDistance(), BALL::TFFT2D< ComplexTraits >::getFourierSpaceMaxX(), BALL::TFFT2D< ComplexTraits >::getFourierSpaceMinX(), BALL::TFFT2D< ComplexTraits >::getGridCoordinates(), BALL::TFFT2D< ComplexTraits >::getInterpolatedValue(), BALL::TVector2< T >::getLength(), BALL::TFFT2D< ComplexTraits >::getPhysSpaceMaxX(), BALL::TFFT2D< ComplexTraits >::getPhysSpaceMinX(), BALL::TVector2< T >::getSquareDistance(), BALL::TVector2< T >::getSquareLength(), BALL::TVector2< T >::isZero(), BALL::TVector2< T >::negate(), BALL::TVector2< T >::normalize(), BALL::TVector2< T >::operator!=(), BALL::operator*(), BALL::TVector2< T >::operator*(), BALL::TVector2< T >::operator*=(), BALL::TVector2< T >::operator+(), BALL::TVector2< T >::operator+=(), BALL::TVector2< T >::operator-(), BALL::TVector2< T >::operator-=(), BALL::TVector2< T >::operator=(), BALL::TVector2< T >::operator==(), BALL::TFFT2D< ComplexTraits >::operator==(), BALL::operator>>(), BALL::TFFT2D< ComplexTraits >::phase(), BALL::TVector2< T >::set(), BALL::TFFT2D< ComplexTraits >::setPhysStepWidth(), and BALL::TFFT2D< ComplexTraits >::translate().
T BALL::TVector2< T >::y |
y component of the vector
Referenced by BALL::TVector2< T >::clear(), BALL::TVector2< T >::dump(), BALL::TVector2< T >::getDistance(), BALL::TFFT2D< ComplexTraits >::getFourierSpaceMaxY(), BALL::TFFT2D< ComplexTraits >::getFourierSpaceMinY(), BALL::TFFT2D< ComplexTraits >::getGridCoordinates(), BALL::TFFT2D< ComplexTraits >::getInterpolatedValue(), BALL::TVector2< T >::getLength(), BALL::TFFT2D< ComplexTraits >::getPhysSpaceMaxY(), BALL::TFFT2D< ComplexTraits >::getPhysSpaceMinY(), BALL::TVector2< T >::getSquareDistance(), BALL::TVector2< T >::getSquareLength(), BALL::TVector2< T >::isZero(), BALL::TVector2< T >::negate(), BALL::TVector2< T >::normalize(), BALL::TVector2< T >::operator!=(), BALL::operator*(), BALL::TVector2< T >::operator*(), BALL::TVector2< T >::operator*=(), BALL::TVector2< T >::operator+(), BALL::TVector2< T >::operator+=(), BALL::TVector2< T >::operator-(), BALL::TVector2< T >::operator-=(), BALL::TVector2< T >::operator=(), BALL::TVector2< T >::operator==(), BALL::TFFT2D< ComplexTraits >::operator==(), BALL::operator>>(), BALL::TFFT2D< ComplexTraits >::phase(), BALL::TVector2< T >::set(), BALL::TFFT2D< ComplexTraits >::setPhysStepWidth(), and BALL::TFFT2D< ComplexTraits >::translate().