HyperspaceExplorer 0.7.1
Public Member Functions | Static Public Member Functions | Private Attributes
VecMath::Vector< D, N > Class Template Reference

Vector<D, N>: a D-dimensional vector of numbers of type N. More...

#include <Vector.h>

Inheritance diagram for VecMath::Vector< D, N >:
Inheritance graph
[legend]
Collaboration diagram for VecMath::Vector< D, N >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Vector ()
 Default constructor.
 Vector (const N &x)
 Make all elements have the same size.
 Vector (N x0, N x1,...)
 Constructor with variable argument list.
N & operator[] (unsigned i)
 Returns a reference to component i.
operator[] (unsigned i) const
 Returns component i by value.
Vector< D, N > & operator+= (const Vector< D, N > &Y)
Vector< D, N > & operator-= (const Vector< D, N > &Y)
Vector< D, N > & operator*= (const N &s)
const N * data () const
 Direct access to the array storing the components.
template<typename T >
 operator const T * () const
 Convert the Vector into an array of arbitrary objects.
std::string toString () const
 Convert Vector to a std::string.

Static Public Member Functions

static unsigned dimension (void)

Private Attributes

_x [D]
 A static array storing the components.

Detailed Description

template<unsigned D, typename N = double>
class VecMath::Vector< D, N >

Vector<D, N>: a D-dimensional vector of numbers of type N.

Template Parameters:
Ddimension of the vector
Nnumerical type of the vector elements
Author:
Lene Preuss <lene.preuss@gmail.com>

Constructor & Destructor Documentation

template<unsigned D, typename N>
VecMath::Vector< D, N >::Vector ( const N &  x)

Make all elements have the same size.

Parameters:
xThe number all Vector components are set to.

References VecMath::Vector< D, N >::_x.

template<unsigned D, typename N>
VecMath::Vector< D, N >::Vector ( x0,
x1,
  ... 
)

Constructor with variable argument list.

To avoid using variable arglists, for D up to 10 you can use makeVector().

Parameters:
x0the vector's first element.
x1the vector's second element.
...the vector's other elements.

References VecMath::Vector< D, N >::_x, and va_end.


Member Function Documentation

template<unsigned D, typename N >
const N * VecMath::Vector< D, N >::data ( ) const

Direct access to the array storing the components.

Needed by glVertex3dv

Referenced by Util::glVertex().

Here is the caller graph for this function:

template<unsigned D, typename N >
unsigned VecMath::Vector< D, N >::dimension ( void  ) [static]
Returns:
dimension of the Vector (the template parameter D)

Referenced by VecMath::operator>>(), and VecMath::Matrix< D, N >::scale().

Here is the caller graph for this function:

template<unsigned D, typename N >
template<typename T >
VecMath::Vector< D, N >::operator const T * ( ) const

Convert the Vector into an array of arbitrary objects.

Array of floats is needed by glLightfv(). Any other type can be a target type as long as a conversion exists from N to T.

Template Parameters:
TThe type of objects the vector elements are converted to. A cast operator to T objects must exist for type N.
template<unsigned D, typename N>
Vector< D, N > & VecMath::Vector< D, N >::operator*= ( const N &  s)
Parameters:
sscalar type
Returns:
*this*s
template<unsigned D, typename N>
Vector< D, N > & VecMath::Vector< D, N >::operator+= ( const Vector< D, N > &  Y)
Parameters:
Yother Vector
Returns:
*this+Y

References VecMath::Vector< D, N >::_x.

template<unsigned D, typename N>
Vector< D, N > & VecMath::Vector< D, N >::operator-= ( const Vector< D, N > &  Y)
Parameters:
Yother Vector
Returns:
*this-Y

References VecMath::Vector< D, N >::_x.

template<unsigned D, typename N >
N VecMath::Vector< D, N >::operator[] ( unsigned  i) const

Returns component i by value.

Parameters:
iindex of the element
Returns:
non-const reference to the accessed element
template<unsigned D, typename N >
N & VecMath::Vector< D, N >::operator[] ( unsigned  i)

Returns a reference to component i.

Parameters:
iindex of the element
Returns:
non-const reference to the accessed element

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends

Generated on Mon Apr 9 2012 20:25:19 for HyperspaceExplorer 0.7.1 by doxygen 1.7.4  -  Hosted bySourceForge.net Logo