BALL  1.4.1
Classes | Typedefs | Functions
Four-dimensional vector.

Classes

class  BALL::TVector4< T >

Typedefs

typedef TVector4< floatBALL::Vector4

Functions

template<typename T >
BALL_INLINE TVector4< T > BALL::operator* (const T &scalar, const TVector4< T > &v)
template<typename T >
BALL_INLINE TVector4< T > BALL::operator* (const TVector4< T > &v, const T &scalar)

Global binary operators for three-dimensional vectors.

template<typename T >
BALL_INLINE TVector4< T > BALL::operator+ (const TVector4< T > &a, const TVector4< T > &b)
template<typename T >
BALL_INLINE TVector4< T > BALL::operator- (const TVector4< T > &a, const TVector4< T > &b)
template<typename T >
std::istream & BALL::operator>> (std::istream &s, TVector4< T > &vector)
template<typename T >
std::ostream & BALL::operator<< (std::ostream &s, const TVector4< T > &vector)

Constructors and Destructors

 BALL::TVector4< T >::TVector4 ()
 BALL::TVector4< T >::TVector4 (const T *ptr)
 BALL::TVector4< T >::TVector4 (const T &value)
 BALL::TVector4< T >::TVector4 (const T &x, const T &y, const T &z, const T &h=(T) 1)
 BALL::TVector4< T >::TVector4 (const TVector4 &vector)
virtual BALL::TVector4< T >::~TVector4 ()
virtual void BALL::TVector4< T >::clear ()

Assignment

void BALL::TVector4< T >::set (const T *ptr)
void BALL::TVector4< T >::set (const T &rx, const T &ry, const T &rz, const T &rh=(T) 1)
void BALL::TVector4< T >::set (const TVector4 &vector)
TVector4 & BALL::TVector4< T >::operator= (const T *ptr)
TVector4 & BALL::TVector4< T >::operator= (const TVector4 &vector)
TVector4 & BALL::TVector4< T >::operator= (T value)
void BALL::TVector4< T >::get (T *ptr) const
void BALL::TVector4< T >::get (T &rx, T &ry, T &rz, T &rh) const
void BALL::TVector4< T >::get (TVector4 &vector) const
void BALL::TVector4< T >::swap (TVector4 &vector)

Accessors

BALL::TVector4< T >::getLength () const
BALL::TVector4< T >::getSquareLength () const
TVector4 & BALL::TVector4< T >::normalize ()
static const TVector4 & BALL::TVector4< T >::getZero ()
static const TVector4 & BALL::TVector4< T >::getUnit ()
void BALL::TVector4< T >::set (const T &value=(T) 1)
T & BALL::TVector4< T >::operator[] (Position position)
const T & BALL::TVector4< T >::operator[] (Position position) const

Arithmetic operators

TVector4 BALL::TVector4< T >::operator+ () const
TVector4 BALL::TVector4< T >::operator- () const
TVector4 & BALL::TVector4< T >::operator+= (const TVector4 &vector)
TVector4 & BALL::TVector4< T >::operator-= (const TVector4 &vector)
TVector4 BALL::TVector4< T >::operator* (const T &scalar)
TVector4 & BALL::TVector4< T >::operator*= (const T &scalar)
TVector4 BALL::TVector4< T >::operator/ (const T &scalar)
TVector4 & BALL::TVector4< T >::operator/= (const T &scalar)
BALL::TVector4< T >::operator* (const TVector4 &vector) const
BALL::TVector4< T >::getDistance (const TVector4 &vector) const
BALL::TVector4< T >::getSquareDistance (const TVector4 &vector) const

Predicates

bool BALL::TVector4< T >::operator== (const TVector4 &vector) const
bool BALL::TVector4< T >::operator!= (const TVector4 &vector) const
bool BALL::TVector4< T >::isOrthogonalTo (const TVector4 &vector) const

Debugging and Diagnostics

bool BALL::TVector4< T >::isValid () const
void BALL::TVector4< T >::dump (std::ostream &s=std::cout, Size depth=0) const

Attributes

All vector components are public members for convenience.

BALL::TVector4< T >::x
BALL::TVector4< T >::y
BALL::TVector4< T >::z
BALL::TVector4< T >::h

Typedef Documentation

typedef TVector4<float> BALL::Vector4

Default four-dimensional vector type

Definition at line 815 of file vector4.h.


Function Documentation

template<typename T >
BALL::TVector4< T >::TVector4 ( )

Default constructor. This method creates a new TVector4 object. The four components are initialized to (T)0.

Definition at line 377 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 ( const T *  ptr)

Array constructor. This constructor creates a TVector4 object from the first four elements pointed by ptr.

Parameters:
ptrthe array to construct from
Exceptions:
NullPointerif ptr == 0

Definition at line 386 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 ( const T &  value) [explicit]

Scalar constructor. Create a new vector with all components set to the same value.

Parameters:
valuethe value of all components

Definition at line 401 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 ( const T &  x,
const T &  y,
const T &  z,
const T &  h = (T)1 
)

Detailed constructor. Create a new TVector4 object from three or four values of type T.

Parameters:
xassigned to x
yassigned to y
zassigned to z
hassigned to h, default: 1 ;

Definition at line 410 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 ( const TVector4< T > &  vector)

Copy constructor. Create a new TVector4 object from another.

Parameters:
vectorthe TVector4 object to be copied

Definition at line 419 of file vector4.h.

template<typename T >
BALL::TVector4< T >::~TVector4 ( ) [virtual]

Destructor. Destructs the TVector4 object. As there are no dynamic data structures, nothing happens.

Definition at line 428 of file vector4.h.

template<typename T>
virtual void BALL::TVector4< T >::clear ( ) [inline, virtual]

Clear method The values are set to 0.

Definition at line 107 of file vector4.h.

template<typename T >
void BALL::TVector4< T >::dump ( std::ostream &  s = std::cout,
Size  depth = 0 
) const

Internal state dump. Dump the current internal state of {*this} to the output ostream s with dumping depth depth .

Parameters:
s- output stream where to output the internal state of {*this}
depth- the dumping depth

Definition at line 798 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::get ( T *  ptr) const

Assign to an array. Sets the first four array elements pointed of array ptr to the values of the four vector components.

Parameters:
ptrthe array
Exceptions:
NullPointerif ptr == 0

Definition at line 508 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::get ( T &  rx,
T &  ry,
T &  rz,
T &  rh 
) const

Assign to four variables of type T.

Parameters:
rxthe x component
rythe y component
rzthe z component
rhthe h component

Definition at line 522 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::get ( TVector4< T > &  vector) const

Assign to another Vector4. Assigns the vector components to another vector.

Parameters:
vectorthe vector to be assigned to

Definition at line 532 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getDistance ( const TVector4< T > &  vector) const

Return the distance to another vector

Parameters:
vectorthe reference vector
Returns:
T, the distance

Definition at line 745 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getLength ( ) const

Return the length of the vector. The length of the vector is calculated as $\sqrt{x^2 + y^2 + z^2 + h^2}$.

Returns:
T, the vector length

Definition at line 562 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getSquareDistance ( const TVector4< T > &  vector) const

Return the squared distance to another vector. This method avoids the square root needed in getDistance, so this method should be preferred if possible.

Parameters:
vectorthe reference vector
Returns:
T, the squared distance

Definition at line 757 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getSquareLength ( ) const

Return the squared length of the vector. This method avoids the square root needed in getLength, so this method should be preferred if possible.

Returns:
T, $x^2 + y^2 + z^2 + h^2$

Definition at line 569 of file vector4.h.

template<typename T >
BALL_INLINE const TVector4< T > & BALL::TVector4< T >::getUnit ( ) [static]

Return a vector with all components 1.

Definition at line 603 of file vector4.h.

template<typename T >
BALL_INLINE const TVector4< T > & BALL::TVector4< T >::getZero ( ) [static]

Return a vector with all components 0.

Definition at line 595 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::isOrthogonalTo ( const TVector4< T > &  vector) const

Orthogonality predicate.

Definition at line 785 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::isValid ( ) const

Test whether instance is valid. Always returns true

Returns:
bool true

Definition at line 792 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::normalize ( )

Normalize the vector. The vector is scaled with its length: $\{x|y|z|h\} *= \sqrt{x^2 + y^2 + z^2 + h^2}$.

Returns:
T, a reference to {*this} vector
Exceptions:
DivisionByZeroif the length of the vector is 0

Definition at line 576 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::operator!= ( const TVector4< T > &  vector) const

Inequality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual

Returns:
bool, true if the two vectors differ in at least one component, false otherwise

Definition at line 777 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator* ( const T &  scalar)

Scalar product. Return TVector4(x * scalar, y * scalar, z * scalar, h * scalar).

Parameters:
scalarthe scalar to multiply by
Returns:
TVector4 the scalar product of this vector and scalar

Definition at line 694 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::operator* ( const TVector4< T > &  vector) const

Dot product.

Parameters:
vectorthe vector to multiply by
Returns:
T the dot product of this vector with vector.

Definition at line 738 of file vector4.h.

template<typename T >
BALL_INLINE TVector4<T> BALL::operator* ( const T &  scalar,
const TVector4< T > &  v 
)

Multiplication operator for a scalar and a vector

Returns:
TVector4 the new vector

Definition at line 841 of file vector4.h.

template<typename T >
BALL_INLINE TVector4<T> BALL::operator* ( const TVector4< T > &  v,
const T &  scalar 
)

Multiplication operator for a vector and a scalar

Returns:
TVector4 the new vector

Definition at line 851 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator*= ( const T &  scalar)

Multiply by a scalar. Multiply all components of the vector with a scalar.

Parameters:
scalarthe scalar to multiply by
Returns:
TVector4& {*this}

Definition at line 701 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::operator+ ( const TVector4< T > &  a,
const TVector4< T > &  b 
)

Addition operator for two vectors

Definition at line 821 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator+ ( ) const

Positive sign.

Definition at line 656 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator+= ( const TVector4< T > &  vector)

Add a vector to this vector.

Parameters:
vectorthe vector to add
Returns:
TVector4, {*this}

Definition at line 670 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::operator- ( const TVector4< T > &  a,
const TVector4< T > &  b 
)

Subtraction operator for two vectors

Returns:
TVector4 the new vector

Definition at line 831 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator- ( ) const

Negative sign.

Definition at line 663 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator-= ( const TVector4< T > &  vector)

Subtract a vector from this vector.

Parameters:
vectorthe vector to subtract
Returns:
TVector4 {*this}

Definition at line 682 of file vector4.h.

template<typename T >
TVector4< T > BALL::TVector4< T >::operator/ ( const T &  scalar)

Fraction of a vector. Return TVector4(x / scalar, y / scalar, z / scalar, h / scalar).

Parameters:
scalarthe scalar to divide by
Returns:
TVector4
Exceptions:
Exception::DivisionByZeroif scalar == (T)0

Definition at line 712 of file vector4.h.

template<typename T >
TVector4< T > & BALL::TVector4< T >::operator/= ( const T &  scalar)

Divide a vector by a scalar.

Parameters:
scalarthe scalar to divide by
Returns:
TVector4&, {*this}
Exceptions:
Exception::DivisionByZeroif scalar == (T)0

Definition at line 722 of file vector4.h.

template<typename T >
std::ostream & BALL::operator<< ( std::ostream &  s,
const TVector4< T > &  v 
)

Output Operator. Write the four components of the vector to an output stream. The values are enclosed by brackets.

Example:
(0.1 2.0 0 1)

Definition at line 875 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( const T *  ptr)

Array assignment operator. Assigns the first four elements of an array to the vector components x, y, z and h.

Parameters:
ptrthe array
Exceptions:
NullPointerif ptr == 0

Definition at line 468 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( const TVector4< T > &  vector)

Assignment operator. Assign the vector components from another vector.

Parameters:
vectorthe vector to assign from

Definition at line 484 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( value)

Assignment operator. Assign a constant value to all four vector components.

Parameters:
valuethe constant to assign to x, y, z, h

Definition at line 496 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::operator== ( const TVector4< T > &  vector) const

Equality operator. The function Maths::isEqual is used to compare the values. Maths::isEqual

Returns:
bool, true if all four vector components are equal, false otherwise

Definition at line 769 of file vector4.h.

template<typename T >
std::istream & BALL::operator>> ( std::istream &  s,
TVector4< T > &  v 
)

Input operator Reads four values of type T from an input stream and assigns them to the components x, y, z and h of the vector.

Definition at line 861 of file vector4.h.

template<typename T >
BALL_INLINE T & BALL::TVector4< T >::operator[] ( Position  position)

Mutable array-like access to the components.

Exceptions:
Exception::IndexOverflowif index > 3

Definition at line 618 of file vector4.h.

template<typename T >
BALL_INLINE const T & BALL::TVector4< T >::operator[] ( Position  position) const

Constant array-like access to the components.

Exceptions:
Exception::IndexOverflowif index > 3

Definition at line 637 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const T *  ptr)

Assign from an array. Assign the four components x, y, z and h from the first four elements of the array pointed to by ptr.

Parameters:
ptran array
Exceptions:
Nullpointerif ptr == 0

Definition at line 434 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const T &  rx,
const T &  ry,
const T &  rz,
const T &  rh = (T)1 
)

Assign the vector components.

Parameters:
rxthe new x component
rythe new y component
rzthe new z component
rhthe new h component, default: 1

Definition at line 448 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const TVector4< T > &  vector)

Assign from another TVector4.

Parameters:
vectorthe TVector4 object to assign from

Definition at line 458 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const T &  value = (T)1)

Assign one value to all vector components.

Parameters:
valuethe value to be assigned to, default: 1

Definition at line 611 of file vector4.h.

template<typename T >
void BALL::TVector4< T >::swap ( TVector4< T > &  vector)

Swap the contents of two vectors.

Parameters:
vectorthe vector to swap contents with

Definition at line 541 of file vector4.h.


Variable Documentation

template<typename T>
T BALL::TVector4< T >::h

height component of the vector

Definition at line 370 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::x

x component of the vector

Definition at line 358 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::y

y component of the vector

Definition at line 362 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::z

z component of the vector

Definition at line 366 of file vector4.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines