Four-dimensional vector.
[Primitive datatypes]

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)

Attributes

All vector components are public members for convenience.



BALL::TVector4::x
BALL::TVector4::y
BALL::TVector4::z
BALL::TVector4::h

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::TVector4 ()
 BALL::TVector4::TVector4 (const T *ptr) throw (Exception::NullPointer)
 BALL::TVector4::TVector4 (const T &value)
 BALL::TVector4::TVector4 (const T &x, const T &y, const T &z, const T &h=(T) 1)
 BALL::TVector4::TVector4 (const TVector4 &vector)
virtual BALL::TVector4::~TVector4 ()
virtual void BALL::TVector4::clear ()

Assignment



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

Accessors



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

Arithmetic operators



TVector4 BALL::TVector4::operator+ () const
TVector4 BALL::TVector4::operator- () const
TVector4 & BALL::TVector4::operator+= (const TVector4 &vector)
TVector4 & BALL::TVector4::operator-= (const TVector4 &vector)
TVector4 BALL::TVector4::operator* (const T &scalar)
TVector4 & BALL::TVector4::operator*= (const T &scalar)
TVector4 BALL::TVector4::operator/ (const T &scalar) throw (Exception::DivisionByZero)
TVector4 & BALL::TVector4::operator/= (const T &scalar) throw (Exception::DivisionByZero)
BALL::TVector4::operator* (const TVector4 &vector) const
BALL::TVector4::getDistance (const TVector4 &vector) const
BALL::TVector4::getSquareDistance (const TVector4 &vector) const

Predicates



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

Debugging and Diagnostics



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

Typedef Documentation

typedef TVector4<float> BALL::Vector4

Default four-dimensional vector type

Definition at line 873 of file vector4.h.


Function Documentation

template<typename T >
BALL::TVector4< T >::TVector4 ( const TVector4< T > &  vector  )  [inline, inherited]

Copy constructor. Create a new TVector4 object from another.

Parameters:
vector the TVector4 object to be copied

Definition at line 440 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 
) [inline, inherited]

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

Parameters:
x assigned to x
y assigned to y
z assigned to z
h assigned to h, default: 1 ;

Definition at line 430 of file vector4.h.

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

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

Parameters:
value the value of all components

Definition at line 420 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 ( const T *  ptr  )  throw (Exception::NullPointer) [inline, inherited]

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

Parameters:
ptr the array to construct from
Exceptions:
NullPointer if ptr == 0

Definition at line 404 of file vector4.h.

template<typename T >
BALL::TVector4< T >::TVector4 (  )  [inline, inherited]

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

Definition at line 394 of file vector4.h.

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

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

Definition at line 450 of file vector4.h.

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

Clear method The values are set to 0.

Definition at line 110 of file vector4.h.

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

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 855 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::get ( TVector4< T > &  vector  )  const [inline, inherited]

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

Parameters:
vector the vector to be assigned to

Definition at line 563 of file vector4.h.

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

Assign to four variables of type T.

Parameters:
rx the x component
ry the y component
rz the z component
rh the h component

Definition at line 552 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::get ( T *  ptr  )  const throw (Exception::NullPointer) [inline, inherited]

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

Parameters:
ptr the array
Exceptions:
NullPointer if ptr == 0

Definition at line 537 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getDistance ( const TVector4< T > &  vector  )  const [inline, inherited]

Return the distance to another vector

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

Definition at line 796 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getLength (  )  const [inline, inherited]

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 595 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getSquareDistance ( const TVector4< T > &  vector  )  const [inline, inherited]

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:
vector the reference vector
Returns:
T, the squared distance

Definition at line 809 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::getSquareLength (  )  const [inline, inherited]

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 603 of file vector4.h.

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

Return a vector with all components 1.

Definition at line 641 of file vector4.h.

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

Return a vector with all components 0.

Definition at line 632 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::isOrthogonalTo ( const TVector4< T > &  vector  )  const [inline, inherited]

Orthogonality predicate.

Definition at line 840 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::isValid (  )  const [inline, inherited]

Test whether instance is valid. Always returns true

Returns:
bool true

Definition at line 848 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::normalize (  )  throw (Exception::DivisionByZero) [inline, inherited]

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:
DivisionByZero if the length of the vector is 0

Definition at line 612 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::operator!= ( const TVector4< T > &  vector  )  const [inline, inherited]

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 831 of file vector4.h.

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

Multiplication operator for a vector and a scalar

Returns:
TVector4 the new vector

Definition at line 912 of file vector4.h.

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

Multiplication operator for a scalar and a vector

Returns:
TVector4 the new vector

Definition at line 901 of file vector4.h.

template<typename T >
BALL_INLINE T BALL::TVector4< T >::operator* ( const TVector4< T > &  vector  )  const [inline, inherited]

Dot product.

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

Definition at line 788 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator* ( const T &  scalar  )  [inline, inherited]

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

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

Definition at line 740 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator*= ( const T &  scalar  )  [inline, inherited]

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

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

Definition at line 748 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator+ (  )  const [inline, inherited]

Positive sign.

Definition at line 698 of file vector4.h.

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

Addition operator for two vectors

Definition at line 879 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator+= ( const TVector4< T > &  vector  )  [inline, inherited]

Add a vector to this vector.

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

Definition at line 714 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > BALL::TVector4< T >::operator- (  )  const [inline, inherited]

Negative sign.

Definition at line 706 of file vector4.h.

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

Subtraction operator for two vectors

Returns:
TVector4 the new vector

Definition at line 890 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator-= ( const TVector4< T > &  vector  )  [inline, inherited]

Subtract a vector from this vector.

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

Definition at line 727 of file vector4.h.

template<typename T >
TVector4< T > BALL::TVector4< T >::operator/ ( const T &  scalar  )  throw (Exception::DivisionByZero) [inline, inherited]

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

Parameters:
scalar the scalar to divide by
Returns:
TVector4
Exceptions:
Exception::DivisionByZero if scalar == (T)0

Definition at line 760 of file vector4.h.

template<typename T >
TVector4< T > & BALL::TVector4< T >::operator/= ( const T &  scalar  )  throw (Exception::DivisionByZero) [inline, inherited]

Divide a vector by a scalar.

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

Definition at line 771 of file vector4.h.

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

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 939 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( value  )  [inline, inherited]

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

Parameters:
value the constant to assign to x, y, z, h

Definition at line 524 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( const TVector4< T > &  vector  )  [inline, inherited]

Assignment operator. Assign the vector components from another vector.

Parameters:
vector the vector to assign from

Definition at line 511 of file vector4.h.

template<typename T >
BALL_INLINE TVector4< T > & BALL::TVector4< T >::operator= ( const T *  ptr  )  throw (Exception::NullPointer) [inline, inherited]

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

Parameters:
ptr the array
Exceptions:
NullPointer if ptr == 0

Definition at line 494 of file vector4.h.

template<typename T >
BALL_INLINE bool BALL::TVector4< T >::operator== ( const TVector4< T > &  vector  )  const [inline, inherited]

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 822 of file vector4.h.

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

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 924 of file vector4.h.

template<typename T >
BALL_INLINE const T & BALL::TVector4< T >::operator[] ( Position  position  )  const throw (Exception::IndexOverflow) [inline, inherited]

Constant array-like access to the components.

Exceptions:
Exception::IndexOverflow if index > 3

Definition at line 678 of file vector4.h.

template<typename T >
BALL_INLINE T & BALL::TVector4< T >::operator[] ( Position  position  )  throw (Exception::IndexOverflow) [inline, inherited]

Mutable array-like access to the components.

Exceptions:
Exception::IndexOverflow if index > 3

Definition at line 658 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const T &  value = (T)1  )  [inline, inherited]

Assign one value to all vector components.

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

Definition at line 650 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const TVector4< T > &  vector  )  [inline, inherited]

Assign from another TVector4.

Parameters:
vector the TVector4 object to assign from

Definition at line 483 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 
) [inline, inherited]

Assign the vector components.

Parameters:
rx the new x component
ry the new y component
rz the new z component
rh the new h component, default: 1

Definition at line 472 of file vector4.h.

template<typename T >
BALL_INLINE void BALL::TVector4< T >::set ( const T *  ptr  )  throw (Exception::NullPointer) [inline, inherited]

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:
ptr an array
Exceptions:
Nullpointer if ptr == 0

Definition at line 457 of file vector4.h.

template<typename T >
void BALL::TVector4< T >::swap ( TVector4< T > &  vector  )  [inline, inherited]

Swap the contents of two vectors.

Parameters:
vector the vector to swap contents with

Definition at line 573 of file vector4.h.


Variable Documentation

template<typename T>
T BALL::TVector4< T >::h [inherited]

height component of the vector

Definition at line 387 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::x [inherited]

x component of the vector

Definition at line 375 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::y [inherited]

y component of the vector

Definition at line 379 of file vector4.h.

template<typename T>
T BALL::TVector4< T >::z [inherited]

z component of the vector

Definition at line 383 of file vector4.h.

Generated by  doxygen 1.6.3