Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

gmtl::VecBase Class Template Reference

Base type for vector-like objects including Points and Vectors. More...

#include <VecBase.h>

Inheritance diagram for gmtl::VecBase:

Inheritance graph
[legend]
Collaboration diagram for gmtl::VecBase:

Collaboration graph
[legend]
List of all members.

Public Types

typedef DATA_TYPE DataType
 The datatype used for the components of this VecBase. More...

enum  Params { Size = SIZE }
 The number of components this VecBase has. More...


Public Methods

 VecBase ()
 Default constructor. More...

 VecBase (const VecBase< DATA_TYPE, SIZE > &rVec)
 Makes an exact copy of the given VecBase object. More...

void set (const DATA_TYPE *dataPtr)
 Sets the components in this VecBase using the given array. More...

 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1)
 Creates a new VecBase initialized to the given values. More...

 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2)
 Creates a new VecBase initialized to the given values. More...

 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2, const DATA_TYPE &val3)
 Creates a new VecBase initialized to the given values. More...

void set (const DATA_TYPE &val0)
 Sets the components in this VecBase to the given values. More...

void set (const DATA_TYPE &val0, const DATA_TYPE &val1)
 Sets the components in this VecBase to the given values. More...

void set (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2)
 Sets the components in this VecBase to the given values. More...

void set (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2, const DATA_TYPE &val3)
 Sets the components in this VecBase to the given values. More...

DATA_TYPE & operator[] (const unsigned i)
 Gets the ith component in this VecBase. More...

const DATA_TYPE & operator[] (const unsigned i) const
 Gets the ith component in this VecBase. More...

DATA_TYPE * getData ()
 Gets the internal array of the components. More...

const DATA_TYPE * getData () const
 Gets the internal array of the components. More...


Public Attributes

DATA_TYPE mData [SIZE]
 The array of components. More...


Detailed Description

template<class DATA_TYPE, unsigned SIZE>
class gmtl::VecBase< DATA_TYPE, SIZE >

Base type for vector-like objects including Points and Vectors.

It is templated on the component datatype as well as the number of components that make it up.

Parameters:
DATA_TYPE  the datatype to use for the components
SIZE  the number of components this VecBase has

Definition at line 52 of file VecBase.h.


Member Typedef Documentation

template<class DATA_TYPE, unsigned SIZE>
typedef DATA_TYPE gmtl::VecBase::DataType
 

The datatype used for the components of this VecBase.

Reimplemented in gmtl::Point.

Definition at line 56 of file VecBase.h.


Member Enumeration Documentation

template<class DATA_TYPE, unsigned SIZE>
enum gmtl::VecBase::Params
 

The number of components this VecBase has.

Enumeration values:
Size 

Reimplemented in gmtl::Point.

Definition at line 59 of file VecBase.h.

00059 { Size = SIZE };


Constructor & Destructor Documentation

template<class DATA_TYPE, unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE >::VecBase   [inline]
 

Default constructor.

Does nothing, leaves data alone. This is for performance because this constructor is called by derived class constructors Even when they just want to set the data directly

Definition at line 68 of file VecBase.h.

00068 {}

template<class DATA_TYPE, unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE >::VecBase const VecBase< DATA_TYPE, SIZE > &    rVec
 

Makes an exact copy of the given VecBase object.

Parameters:
rVec  the VecBase object to copy

Definition at line 144 of file VecBase.h.

References mData.

00145 {
00146    for(unsigned i=0;i<SIZE;++i)
00147       mData[i] = rVec.mData[i];
00148 }

template<class DATA_TYPE, unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE >::VecBase const DATA_TYPE &    val0,
const DATA_TYPE &    val1
 

Creates a new VecBase initialized to the given values.

Definition at line 151 of file VecBase.h.

References gmtlASSERT, and mData.

00152 {
00153    // @todo need compile time assert
00154    gmtlASSERT( SIZE == 2 && "out of bounds element access in VecBase" );
00155    mData[0] = val0;
00156    mData[1] = val1;
00157 }

template<class DATA_TYPE, unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE >::VecBase const DATA_TYPE &    val0,
const DATA_TYPE &    val1,
const DATA_TYPE &    val2
 

Creates a new VecBase initialized to the given values.

Definition at line 160 of file VecBase.h.

References gmtlASSERT, and mData.

00161 {
00162    // @todo need compile time assert
00163    gmtlASSERT( SIZE == 3 && "out of bounds element access in VecBase" );
00164    mData[0] = val0;
00165    mData[1] = val1;
00166    mData[2] = val2;
00167 }

template<class DATA_TYPE, unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE >::VecBase const DATA_TYPE &    val0,
const DATA_TYPE &    val1,
const DATA_TYPE &    val2,
const DATA_TYPE &    val3
 

Creates a new VecBase initialized to the given values.

Definition at line 170 of file VecBase.h.

References gmtlASSERT, and mData.

00171 {
00172    // @todo need compile time assert
00173    gmtlASSERT( SIZE == 4 && "out of bounds element access in VecBase" );
00174    mData[0] = val0;
00175    mData[1] = val1;
00176    mData[2] = val2;
00177    mData[3] = val3;
00178 }


Member Function Documentation

template<class DATA_TYPE, unsigned SIZE>
const DATA_TYPE* gmtl::VecBase< DATA_TYPE, SIZE >::getData   const [inline]
 

Gets the internal array of the components.

Returns:
a pointer to the component array with length SIZE

Definition at line 133 of file VecBase.h.

00134    { return mData; }

template<class DATA_TYPE, unsigned SIZE>
DATA_TYPE* gmtl::VecBase< DATA_TYPE, SIZE >::getData   [inline]
 

Gets the internal array of the components.

Returns:
a pointer to the component array with length SIZE

Definition at line 131 of file VecBase.h.

00132    { return mData; }

template<class DATA_TYPE, unsigned SIZE>
const DATA_TYPE& gmtl::VecBase< DATA_TYPE, SIZE >::operator[] const unsigned    i const [inline]
 

Gets the ith component in this VecBase.

Parameters:
i  the zero-based index of the component to access.
Precondition:
i < SIZE
Returns:
a reference to the ith component

Definition at line 118 of file VecBase.h.

00119    {
00120       gmtlASSERT(i < SIZE);
00121       return mData[i];
00122    }

template<class DATA_TYPE, unsigned SIZE>
DATA_TYPE& gmtl::VecBase< DATA_TYPE, SIZE >::operator[] const unsigned    i [inline]
 

Gets the ith component in this VecBase.

Parameters:
i  the zero-based index of the component to access.
Precondition:
i < SIZE
Returns:
a reference to the ith component

Definition at line 113 of file VecBase.h.

00114    {
00115       gmtlASSERT(i < SIZE);
00116       return mData[i];
00117    }

template<class DATA_TYPE, unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE >::set const DATA_TYPE &    val0,
const DATA_TYPE &    val1,
const DATA_TYPE &    val2,
const DATA_TYPE &    val3
[inline]
 

Sets the components in this VecBase to the given values.

Reimplemented in gmtl::AxisAngle.

Definition at line 210 of file VecBase.h.

References gmtlASSERT, and mData.

00211 {
00212    gmtlASSERT( SIZE >= 4 && "out of bounds element access in VecBase" );
00213    mData[0] = val0;
00214    mData[1] = val1;
00215    mData[2] = val2;
00216    mData[3] = val3;
00217 }

template<class DATA_TYPE, unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE >::set const DATA_TYPE &    val0,
const DATA_TYPE &    val1,
const DATA_TYPE &    val2
[inline]
 

Sets the components in this VecBase to the given values.

Definition at line 202 of file VecBase.h.

References gmtlASSERT, and mData.

00203 {
00204    gmtlASSERT( SIZE >= 3 && "out of bounds element access in VecBase" );
00205    mData[0] = val0;
00206    mData[1] = val1;
00207    mData[2] = val2;
00208 }

template<class DATA_TYPE, unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE >::set const DATA_TYPE &    val0,
const DATA_TYPE &    val1
[inline]
 

Sets the components in this VecBase to the given values.

Definition at line 195 of file VecBase.h.

References gmtlASSERT, and mData.

00196 {
00197    gmtlASSERT( SIZE >= 2 && "out of bounds element access in VecBase" );
00198    mData[0] = val0;
00199    mData[1] = val1;
00200 }

template<class DATA_TYPE, unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE >::set const DATA_TYPE &    val0 [inline]
 

Sets the components in this VecBase to the given values.

Definition at line 189 of file VecBase.h.

References gmtlASSERT, and mData.

00190 {
00191    gmtlASSERT( SIZE >= 1 && "out of bounds element access in VecBase" );
00192    mData[0] = val0;
00193 }

template<class DATA_TYPE, unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE >::set const DATA_TYPE *    dataPtr [inline]
 

Sets the components in this VecBase using the given array.

Parameters:
dataPtr  the array containing the values to copy
Precondition:
dataPtr has at least SIZE elements

Definition at line 183 of file VecBase.h.

References mData.

00184 {
00185    for(unsigned i=0;i<SIZE;++i)
00186       mData[i] = dataPtr[i];
00187 }


Member Data Documentation

template<class DATA_TYPE, unsigned SIZE>
DATA_TYPE gmtl::VecBase::mData[SIZE]
 

The array of components.

Definition at line 139 of file VecBase.h.

Referenced by gmtl::VecBase< DATA_TYPE, 4 >::getData, gmtl::VecBase< DATA_TYPE, 4 >::operator[], gmtl::Point< DATA_TYPE, 3 >::Point, set, gmtl::Vec< DATA_TYPE, 4 >::Vec, and VecBase.


The documentation for this class was generated from the following file:
Generated on Mon Apr 7 15:29:33 2003 for GenericMathTemplateLibrary by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002